2017-09-25 14:53:25 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-02-25 21:03:13 +01:00
|
|
|
#include "bard_music.h"
|
2019-02-22 18:40:32 +01:00
|
|
|
#include "bg.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2019-02-24 17:04:40 +01:00
|
|
|
#include "decompress.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "dewford_trend.h"
|
|
|
|
#include "dynamic_placeholder_text_util.h"
|
|
|
|
#include "easy_chat.h"
|
|
|
|
#include "event_data.h"
|
2019-02-24 17:04:40 +01:00
|
|
|
#include "event_object_movement.h"
|
2019-02-25 21:03:13 +01:00
|
|
|
#include "field_message_box.h"
|
2017-11-03 00:34:19 +01:00
|
|
|
#include "field_weather.h"
|
2019-02-22 18:40:32 +01:00
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "graphics.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "main.h"
|
2021-10-17 09:00:48 +02:00
|
|
|
#include "mystery_gift.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "overworld.h"
|
2017-09-25 14:53:25 +02:00
|
|
|
#include "palette.h"
|
2019-02-25 21:03:13 +01:00
|
|
|
#include "pokedex.h"
|
|
|
|
#include "random.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "sound.h"
|
2018-11-19 18:14:28 +01:00
|
|
|
#include "string_util.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "strings.h"
|
|
|
|
#include "task.h"
|
2019-02-23 19:59:20 +01:00
|
|
|
#include "text_window.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "window.h"
|
2019-02-24 17:04:40 +01:00
|
|
|
#include "constants/event_objects.h"
|
2019-08-06 02:37:09 +02:00
|
|
|
#include "constants/lilycove_lady.h"
|
2019-10-20 22:11:07 +02:00
|
|
|
#include "constants/mauville_old_man.h"
|
2019-02-22 00:40:20 +01:00
|
|
|
#include "constants/songs.h"
|
2019-04-04 23:05:46 +02:00
|
|
|
#include "constants/rgb.h"
|
2017-09-25 14:53:25 +02:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static EWRAM_DATA struct EasyChatScreen *sEasyChatScreen = NULL;
|
2021-02-22 18:12:35 +01:00
|
|
|
static EWRAM_DATA struct EasyChatScreenControl *sScreenControl = NULL;
|
|
|
|
static EWRAM_DATA struct EasyChatScreenWordData *sWordData = NULL;
|
|
|
|
|
|
|
|
static void Task_InitEasyChatScreen(u8);
|
|
|
|
static void CB2_EasyChatScreen(void);
|
|
|
|
static bool8 InitEasyChatScreen(u8);
|
|
|
|
static void Task_EasyChatScreen(u8);
|
|
|
|
static void ExitEasyChatScreen(MainCallback);
|
|
|
|
static bool32 IsFuncIdForQuizLadyScreen(u16);
|
|
|
|
static void EnterQuizLadyScreen(u16);
|
|
|
|
static bool8 InitEasyChatScreenStruct(u8, u16 *, u8);
|
|
|
|
static void FreeEasyChatScreenStruct(void);
|
|
|
|
static u16 HandleEasyChatInput(void);
|
|
|
|
static u16 HandleEasyChatInput_Phrase(void);
|
|
|
|
static u16 HandleEasyChatInput_MainScreenButtons(void);
|
|
|
|
static u16 HandleEasyChatInput_Keyboard(void);
|
|
|
|
static u16 HandleEasyChatInput_WordSelect(void);
|
|
|
|
static u16 HandleEasyChatInput_ExitPrompt(void);
|
|
|
|
static u16 HandleEasyChatInput_ConfirmWordsYesNo(void);
|
|
|
|
static u16 HandleEasyChatInput_DeleteAllYesNo(void);
|
|
|
|
static u16 HandleEasyChatInput_QuizQuestion(void);
|
|
|
|
static u16 HandleEasyChatInput_WaitForMsg(void);
|
|
|
|
static u16 HandleEasyChatInput_StartConfirmLyrics(void);
|
|
|
|
static u16 HandleEasyChatInput_ConfirmLyricsYesNo(void);
|
|
|
|
static u16 StartConfirmExitPrompt(void);
|
|
|
|
static u16 TryConfirmWords(void);
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetEasyChatScreenFrameId(void);
|
|
|
|
static u8 GetEachChatScreenTemplateId(u8);
|
2021-02-22 18:12:35 +01:00
|
|
|
static void GetQuizTitle(u8 *);
|
|
|
|
static void ClearUnusedField(void);
|
|
|
|
static bool8 InitEasyChatScreenControl(void);
|
|
|
|
static bool8 LoadEasyChatScreen(void);
|
|
|
|
static void FreeEasyChatScreenControl(void);
|
|
|
|
static void StartEasyChatFunction(u16);
|
|
|
|
static bool8 RunEasyChatFunction(void);
|
|
|
|
static bool8 InitEasyChatScreenWordData(void);
|
|
|
|
static void FreeEasyChatScreenWordData(void);
|
|
|
|
static u8 GetNumUnlockedEasyChatGroups(void);
|
2019-02-27 19:45:31 +01:00
|
|
|
static int FooterHasFourOptions(void);
|
2021-02-22 18:12:35 +01:00
|
|
|
static int DoDeleteAllButton(void);
|
|
|
|
static int DoQuizButton(void);
|
|
|
|
static int ExitKeyboardToMainScreen(void);
|
|
|
|
static int SelectKeyboardGroup(void);
|
|
|
|
static int StartSwitchKeyboardMode(void);
|
|
|
|
static int DeleteSelectedWord(void);
|
|
|
|
static u16 MoveKeyboardCursor(int);
|
|
|
|
static u16 MoveWordSelectCursor(u32);
|
|
|
|
static int SelectNewWord(void);
|
|
|
|
static u8 GetEasyChatBackupState(void);
|
|
|
|
static void SaveCurrentPhrase(void);
|
|
|
|
static void SetSpecialEasyChatResult(void);
|
|
|
|
static bool32 GetEasyChatCompleted(void);
|
|
|
|
static void ResetCurrentPhrase(void);
|
|
|
|
static void ResetCurrentPhraseToSaved(void);
|
|
|
|
static int IsQuizQuestionEmpty(void);
|
|
|
|
static int IsQuizAnswerEmpty(void);
|
|
|
|
static bool32 IsCurrentPhraseFull(void);
|
|
|
|
static bool32 IsCurrentPhraseEmpty(void);
|
|
|
|
static u16 GetSelectedGroupIndex(void);
|
|
|
|
static u8 GetUnlockedEasyChatGroupId(u8);
|
|
|
|
static void SetSelectedWordGroup(bool32, u16);
|
|
|
|
static int GetSelectedAlphabetGroupId(void);
|
|
|
|
static u16 GetNumWordsInSelectedGroup(void);
|
|
|
|
static void SetSelectedWord(u16);
|
|
|
|
static u16 GetSelectedWordIndex(void);
|
|
|
|
static u16 GetWordFromSelectedGroup(u16);
|
|
|
|
static bool32 DummyWordCheck(int);
|
|
|
|
static u16 GetWordIndexToReplace(void);
|
|
|
|
static int MoveKeyboardCursor_GroupNames(u32);
|
|
|
|
static int MoveKeyboardCursor_Alphabet(u32);
|
|
|
|
static int MoveKeyboardCursor_ButtonWindow(u32);
|
|
|
|
static void ReduceToValidKeyboardColumn(void);
|
|
|
|
static void SetKeyboardCursorInButtonWindow(void);
|
|
|
|
static bool8 IsSelectedKeyboardIndexInvalid(void);
|
|
|
|
static void SetKeyboardCursorToLastColumn(void);
|
|
|
|
static u8 GetLastAlphabetColumn(u8);
|
|
|
|
static void ReduceToValidWordSelectColumn(void);
|
|
|
|
static bool8 IsSelectedWordIndexInvalid(void);
|
2019-10-07 16:34:12 +02:00
|
|
|
static int DidPlayerInputMysteryGiftPhrase(void);
|
|
|
|
static u16 DidPlayerInputABerryMasterWifePhrase(void);
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 InitEasyChatScreenControl_(void);
|
|
|
|
static void LoadEasyChatPalettes(void);
|
|
|
|
static void InitEasyChatBgs(void);
|
|
|
|
static void AdjustBgTilemapForFooter(void);
|
|
|
|
static void BufferFrameTilemap(u16 *);
|
|
|
|
static void AddPhraseWindow(void);
|
|
|
|
static void AddMainScreenButtonWindow(void);
|
|
|
|
static void PrintTitle(void);
|
|
|
|
static void PrintInitialInstructions(void);
|
|
|
|
static void PrintCurrentPhrase(void);
|
|
|
|
static void DrawLowerWindow(void);
|
|
|
|
static void LoadEasyChatGfx(void);
|
|
|
|
static void CreateMainCursorSprite(void);
|
|
|
|
static void SpriteCB_Cursor(struct Sprite *);
|
|
|
|
static void SetWindowDimensions(u8, u8, u8, u8);
|
|
|
|
static void CreateScrollIndicatorSprites(void);
|
|
|
|
static void CreateStartSelectButtonSprites(void);
|
|
|
|
static void TryAddInterviewObjectEvents(void);
|
|
|
|
static bool8 ReprintPhrase(void);
|
|
|
|
static bool8 UpdateMainCursor(void);
|
|
|
|
static bool8 UpdateMainCursorOnButtons(void);
|
|
|
|
static bool8 ShowConfirmDeleteAllPrompt(void);
|
|
|
|
static bool8 ShowConfirmExitPrompt(void);
|
|
|
|
static bool8 ShowConfirmPrompt(void);
|
|
|
|
static bool8 ClosePrompt(void);
|
|
|
|
static bool8 ClosePromptAfterDeleteAll(void);
|
|
|
|
static bool8 OpenKeyboard(void);
|
|
|
|
static bool8 CloseKeyboard(void);
|
|
|
|
static bool8 OpenWordSelect(void);
|
|
|
|
static bool8 CloseWordSelect(void);
|
|
|
|
static bool8 ShowConfirmLyricsPrompt(void);
|
|
|
|
static bool8 ReturnToKeyboard(void);
|
|
|
|
static bool8 UpdateKeyboardCursor(void);
|
|
|
|
static bool8 GroupNamesScrollDown(void);
|
|
|
|
static bool8 GroupNamesScrollUp(void);
|
|
|
|
static bool8 UpdateWordSelectCursor(void);
|
|
|
|
static bool8 WordSelectScrollUp(void);
|
|
|
|
static bool8 WordSelectScrollDown(void);
|
|
|
|
static bool8 WordSelectPageScrollUp(void);
|
|
|
|
static bool8 WordSelectPageScrollDown(void);
|
|
|
|
static bool8 SwitchKeyboardMode(void);
|
|
|
|
static bool8 ShowCreateQuizMsg(void);
|
|
|
|
static bool8 ShowSelectAnswerMsg(void);
|
|
|
|
static bool8 ShowSongTooShortMsg(void);
|
|
|
|
static bool8 ShowCantDeleteLyricsMsg(void);
|
|
|
|
static bool8 ShowCombineTwoWordsMsg(void);
|
|
|
|
static bool8 ShowCantExitMsg(void);
|
|
|
|
static void SetMainCursorPos(u8, u8);
|
2019-02-27 19:45:31 +01:00
|
|
|
static int GetFooterOptionXOffset(int);
|
2021-02-22 18:12:35 +01:00
|
|
|
static void StopMainCursorAnim(void);
|
|
|
|
static void PrintEasyChatStdMessage(u8);
|
|
|
|
static void CreateEasyChatYesNoMenu(u8);
|
|
|
|
static void StartMainCursorAnim(void);
|
|
|
|
static void PrintKeyboardText(void);
|
|
|
|
static void InitLowerWindowAnim(int);
|
|
|
|
static void CreateSideWindowSprites(void);
|
|
|
|
static bool8 ShowSideWindow(void);
|
|
|
|
static void CreateRectangleCursorSprites(void);
|
|
|
|
static void SetScrollIndicatorXPos(bool32);
|
|
|
|
static bool8 UpdateLowerWindowAnim(void);
|
|
|
|
static void UpdateScrollIndicatorsVisibility(void);
|
|
|
|
static void DestroyRectangleCursorSprites(void);
|
|
|
|
static void HideModeWindow(void);
|
|
|
|
static void HideScrollIndicators(void);
|
|
|
|
static void SetModeWindowToTransition(void);
|
|
|
|
static bool8 DestroySideWindowSprites(void);
|
|
|
|
static bool8 IsModeWindowAnimActive(void);
|
|
|
|
static void UpdateModeWindowAnim(void);
|
|
|
|
static void UpdateRectangleCursorPos(void);
|
|
|
|
static void InitLowerWindowScroll(s16, u8);
|
|
|
|
static bool8 UpdateLowerWindowScroll(void);
|
|
|
|
static void ClearWordSelectWindow(void);
|
|
|
|
static void InitLowerWindowText(u32);
|
|
|
|
static void CreateWordSelectCursorSprite(void);
|
|
|
|
static void UpdateStartSelectButtonsVisibility(void);
|
|
|
|
static void DestroyWordSelectCursorSprite(void);
|
|
|
|
static void HideStartSelectButtons(void);
|
|
|
|
static void UpdateWordSelectCursorPos(void);
|
|
|
|
static void PrintWordSelectNextRowDown(void);
|
|
|
|
static void PrintWordSelectNextRowUp(void);
|
|
|
|
static int GetLowerWindowScrollOffset(void);
|
|
|
|
static void PrintWordSelectRowsPageDown(void);
|
|
|
|
static void PrintWordSelectRowsPageUp(void);
|
|
|
|
static void PrintEasyChatTextWithColors(u8, u8, const u8 *, u8, u8, u8, u8, u8, u8);
|
|
|
|
static void ResetLowerWindowScroll(void);
|
|
|
|
static void PrintKeyboardGroupNames(void);
|
|
|
|
static void PrintKeyboardAlphabet(void);
|
|
|
|
static void PrintInitialWordSelectText(void);
|
2019-02-26 18:17:41 +01:00
|
|
|
static const u8 *GetEasyChatWordGroupName(u8);
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintWordSelectText(u8, u8);
|
|
|
|
static void EraseWordSelectRows(u8, u8);
|
|
|
|
static void DrawLowerWindowFrame(u8);
|
|
|
|
static void BufferLowerWindowFrame(int, int, int, int);
|
|
|
|
static void SetRectangleCursorPos_GroupMode(s8, s8);
|
|
|
|
static void SetRectangleCursorPos_AlphabetMode(s8, s8);
|
|
|
|
static void SpriteCB_WordSelectCursor(struct Sprite *);
|
|
|
|
static void SetWordSelectCursorPos(u8, u8);
|
2019-10-20 22:11:07 +02:00
|
|
|
static bool8 EasyChatIsNationalPokedexEnabled(void);
|
2020-01-08 21:26:14 +01:00
|
|
|
static u16 GetRandomUnlockedEasyChatPokemon(void);
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetUnlockedEasyChatGroups(void);
|
|
|
|
static void SetUnlockedWordsByAlphabet(void);
|
2019-02-26 18:17:41 +01:00
|
|
|
static u8 *CopyEasyChatWordPadded(u8 *, u16, u16);
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 IsEasyChatWordUnlocked(u16);
|
|
|
|
static u16 SetSelectedWordGroup_GroupMode(u16);
|
|
|
|
static u16 SetSelectedWordGroup_AlphabetMode(u16);
|
|
|
|
static bool8 IsEasyChatIndexAndGroupUnlocked(u16, u8);
|
|
|
|
static int IsRestrictedWordSpecies(u16);
|
2019-02-27 19:45:31 +01:00
|
|
|
static void DoQuizAnswerEasyChatScreen(void);
|
|
|
|
static void DoQuizQuestionEasyChatScreen(void);
|
|
|
|
static void DoQuizSetAnswerEasyChatScreen(void);
|
|
|
|
static void DoQuizSetQuestionEasyChatScreen(void);
|
2017-09-25 14:53:25 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
#define PALTAG_TRIANGLE_CURSOR 0
|
|
|
|
#define PALTAG_RECTANGLE_CURSOR 1
|
|
|
|
#define PALTAG_MISC_UI 2
|
2021-03-31 22:56:10 +02:00
|
|
|
#define PALTAG_RS_INTERVIEW_FRAME 3
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
#define GFXTAG_TRIANGLE_CURSOR 0
|
|
|
|
#define GFXTAG_RECTANGLE_CURSOR 1
|
|
|
|
#define GFXTAG_SCROLL_INDICATOR 2
|
|
|
|
#define GFXTAG_START_SELECT_BUTTONS 3
|
|
|
|
#define GFXTAG_MODE_WINDOW 4
|
2021-03-31 22:56:10 +02:00
|
|
|
#define GFXTAG_RS_INTERVIEW_FRAME 5
|
2021-02-22 18:12:35 +01:00
|
|
|
#define GFXTAG_BUTTON_WINDOW 6
|
|
|
|
|
|
|
|
// State values for sEasyChatScreen->inputState
|
|
|
|
// Control which input handler to use in HandleEasyChatInput
|
|
|
|
enum {
|
|
|
|
INPUTSTATE_PHRASE,
|
|
|
|
INPUTSTATE_MAIN_SCREEN_BUTTONS,
|
|
|
|
INPUTSTATE_KEYBOARD,
|
|
|
|
INPUTSTATE_WORD_SELECT,
|
|
|
|
INPUTSTATE_EXIT_PROMPT,
|
|
|
|
INPUTSTATE_DELETE_ALL_YES_NO,
|
|
|
|
INPUTSTATE_CONFIRM_WORDS_YES_NO,
|
|
|
|
INPUTSTATE_QUIZ_QUESTION,
|
|
|
|
INPUTSTATE_WAIT_FOR_MSG,
|
|
|
|
INPUTSTATE_START_CONFIRM_LYRICS,
|
|
|
|
INPUTSTATE_CONFIRM_LYRICS_YES_NO,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Task states for the 'main' task, Task_EasyChatScreen
|
|
|
|
enum {
|
|
|
|
MAINSTATE_FADE_IN,
|
|
|
|
MAINSTATE_HANDLE_INPUT,
|
|
|
|
MAINSTATE_RUN_FUNC,
|
|
|
|
MAINSTATE_TO_QUIZ_LADY,
|
|
|
|
MAINSTATE_EXIT,
|
|
|
|
MAINSTATE_WAIT_FADE_IN,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs provided to PrintEasyChatStdMessage to print a standard message
|
|
|
|
enum {
|
|
|
|
MSG_INSTRUCTIONS,
|
|
|
|
MSG_CONFIRM_DELETE,
|
|
|
|
MSG_CONFIRM_EXIT,
|
|
|
|
MSG_CONFIRM,
|
|
|
|
MSG_CREATE_QUIZ,
|
|
|
|
MSG_SELECT_ANSWER,
|
|
|
|
MSG_SONG_TOO_SHORT,
|
|
|
|
MSG_CANT_DELETE_LYRICS,
|
|
|
|
MSG_COMBINE_TWO_WORDS,
|
|
|
|
MSG_CANT_QUIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for supplementary Easy Chat functions
|
|
|
|
// Returned by the input handler functions, and run
|
|
|
|
// in the main task (MAINSTATE_RUN_FUNC)
|
|
|
|
enum {
|
|
|
|
ECFUNC_NONE,
|
|
|
|
ECFUNC_REPRINT_PHRASE,
|
|
|
|
ECFUNC_UPDATE_MAIN_CURSOR,
|
|
|
|
ECFUNC_UPDATE_MAIN_CURSOR_ON_BUTTONS,
|
|
|
|
ECFUNC_PROMPT_DELETE_ALL,
|
|
|
|
ECFUNC_PROMPT_EXIT,
|
|
|
|
ECFUNC_PROMPT_CONFIRM,
|
|
|
|
ECFUNC_CLOSE_PROMPT,
|
|
|
|
ECFUNC_CLOSE_PROMPT_AFTER_DELETE,
|
|
|
|
ECFUNC_OPEN_KEYBOARD,
|
|
|
|
ECFUNC_CLOSE_KEYBOARD,
|
|
|
|
ECFUNC_OPEN_WORD_SELECT,
|
|
|
|
ECFUNC_CLOSE_WORD_SELECT,
|
|
|
|
ECFUNC_PROMPT_CONFIRM_LYRICS,
|
|
|
|
ECFUNC_RETURN_TO_KEYBOARD,
|
|
|
|
ECFUNC_UPDATE_KEYBOARD_CURSOR,
|
|
|
|
ECFUNC_GROUP_NAMES_SCROLL_DOWN,
|
|
|
|
ECFUNC_GROUP_NAMES_SCROLL_UP,
|
|
|
|
ECFUNC_UPDATE_WORD_SELECT_CURSOR,
|
|
|
|
ECFUNC_WORD_SELECT_SCROLL_UP,
|
|
|
|
ECFUNC_WORD_SELECT_SCROLL_DOWN,
|
|
|
|
ECFUNC_WORD_SELECT_PAGE_UP,
|
|
|
|
ECFUNC_WORD_SELECT_PAGE_DOWN,
|
|
|
|
ECFUNC_SWITCH_KEYBOARD_MODE,
|
|
|
|
ECFUNC_EXIT,
|
|
|
|
ECFUNC_QUIZ_QUESTION,
|
|
|
|
ECFUNC_QUIZ_ANSWER,
|
|
|
|
ECFUNC_SET_QUIZ_QUESTION,
|
|
|
|
ECFUNC_SET_QUIZ_ANSWER,
|
|
|
|
ECFUNC_MSG_CREATE_QUIZ,
|
|
|
|
ECFUNC_MSG_SELECT_ANSWER,
|
|
|
|
ECFUNC_MSG_SONG_TOO_SHORT,
|
|
|
|
ECFUNC_MSG_CANT_DELETE_LYRICS,
|
|
|
|
ECFUNC_MSG_COMBINE_TWO_WORDS,
|
|
|
|
ECFUNC_MSG_CANT_EXIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for InitLowerWindowText
|
|
|
|
enum {
|
|
|
|
TEXT_GROUPS,
|
|
|
|
TEXT_ALPHABET,
|
|
|
|
TEXT_WORD_SELECT,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_ALPHABET_ROWS 4
|
|
|
|
#define NUM_GROUP_NAME_ROWS 4
|
|
|
|
#define NUM_WORD_SELECT_ROWS 4
|
|
|
|
#define NUM_BUTTON_ROWS 3
|
|
|
|
|
|
|
|
#define NUM_ALPHABET_COLUMNS 7
|
|
|
|
#define NUM_GROUP_NAME_COLUMNS 2
|
|
|
|
#define NUM_WORD_SELECT_COLUMNS 2
|
|
|
|
|
|
|
|
enum {
|
|
|
|
FRAMEID_GENERAL_2x2,
|
|
|
|
FRAMEID_GENERAL_2x3,
|
|
|
|
FRAMEID_MAIL,
|
|
|
|
FRAMEID_COMBINE_TWO_WORDS,
|
|
|
|
FRAMEID_INTERVIEW_SHOW_PERSON,
|
|
|
|
FRAMEID_INTERVIEW,
|
|
|
|
FRAMEID_QUIZ_ANSWER,
|
|
|
|
FRAMEID_QUIZ_QUESTION,
|
|
|
|
FRAMEID_QUIZ_SET_QUESTION,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for the footer row of buttons on the main screen
|
|
|
|
enum {
|
|
|
|
FOOTER_NORMAL,
|
|
|
|
FOOTER_QUIZ,
|
|
|
|
FOOTER_ANSWER,
|
|
|
|
NUM_FOOTER_TYPES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
INPUT_RIGHT,
|
|
|
|
INPUT_LEFT,
|
|
|
|
INPUT_UP,
|
|
|
|
INPUT_DOWN,
|
|
|
|
INPUT_START,
|
|
|
|
INPUT_SELECT,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Types of animations for the lower window (keyboard/word select), given to InitLowerWindowAnim
|
|
|
|
enum {
|
|
|
|
WINANIM_OPEN_KEYBOARD,
|
|
|
|
WINANIM_CLOSE_KEYBOARD,
|
|
|
|
WINANIM_OPEN_WORD_SELECT,
|
|
|
|
WINANIM_CLOSE_WORD_SELECT,
|
|
|
|
WINANIM_RETURN_TO_KEYBOARD,
|
|
|
|
WINANIM_KEYBOARD_SWITCH_OUT,
|
|
|
|
WINANIM_KEYBOARD_SWITCH_IN,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Values for text frame tilemap
|
|
|
|
#define FRAME_OFFSET_ORANGE 0x1000 // Orange frame, for phrase text
|
|
|
|
#define FRAME_OFFSET_GREEN 0x4000 // Green frame, for keyboard/word select
|
|
|
|
|
|
|
|
#define FRAME_TILE_TRANSPARENT 0x0
|
|
|
|
#define FRAME_TILE_TOP_L_CORNER 0x1
|
|
|
|
#define FRAME_TILE_TOP_EDGE 0x2
|
|
|
|
#define FRAME_TILE_TOP_R_CORNER 0x3
|
|
|
|
#define FRAME_TILE_L_EDGE 0x5
|
|
|
|
#define FRAME_TILE_R_EDGE 0x7
|
|
|
|
#define FRAME_TILE_BOTTOM_L_CORNER 0x9
|
|
|
|
#define FRAME_TILE_BOTTOM_EDGE 0xA
|
|
|
|
#define FRAME_TILE_BOTTOM_R_CORNER 0xB
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 funcId;
|
|
|
|
MainCallback callback;
|
|
|
|
} static const sQuizLadyEasyChatScreens[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.funcId = ECFUNC_QUIZ_ANSWER,
|
2019-02-27 19:45:31 +01:00
|
|
|
.callback = DoQuizAnswerEasyChatScreen,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.funcId = ECFUNC_QUIZ_QUESTION,
|
2019-02-27 19:45:31 +01:00
|
|
|
.callback = DoQuizQuestionEasyChatScreen,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.funcId = ECFUNC_SET_QUIZ_ANSWER,
|
2019-02-27 19:45:31 +01:00
|
|
|
.callback = DoQuizSetAnswerEasyChatScreen,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.funcId = ECFUNC_SET_QUIZ_QUESTION,
|
2019-02-27 19:45:31 +01:00
|
|
|
.callback = DoQuizSetQuestionEasyChatScreen,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
};
|
2019-02-27 19:45:31 +01:00
|
|
|
|
|
|
|
static const struct EasyChatScreenTemplate sEasyChatScreenTemplates[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_PROFILE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x2,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Profile,
|
|
|
|
.instructionsText1 = gText_CombineFourWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeYourProfile,
|
|
|
|
.confirmText1 = gText_YourProfile,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BATTLE_START,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_AtTheBattlesStart,
|
|
|
|
.instructionsText1 = gText_CombineSixWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeAMessage,
|
|
|
|
.confirmText1 = gText_YourFeelingAtTheBattlesStart,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BATTLE_WON,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_UponWinningABattle,
|
|
|
|
.instructionsText1 = gText_CombineSixWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeAMessage,
|
|
|
|
.confirmText1 = gText_WhatYouSayIfYouWin,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BATTLE_LOST,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_UponLosingABattle,
|
|
|
|
.instructionsText1 = gText_CombineSixWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeAMessage,
|
|
|
|
.confirmText1 = gText_WhatYouSayIfYouLose,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_MAIL,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 5,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_MAIL,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = NULL,
|
|
|
|
.instructionsText1 = gText_CombineNineWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeAMessage2,
|
|
|
|
.confirmText1 = gText_TheMailMessage,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_INTERVIEW,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Interview,
|
|
|
|
.instructionsText1 = gText_CombineFourWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_LetsReplyToTheInterview,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BARD_SONG,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_TheBardsSong,
|
|
|
|
.instructionsText1 = gText_ChangeJustOneWordOrPhrase,
|
|
|
|
.instructionsText2 = gText_AndImproveTheBardsSong,
|
|
|
|
.confirmText1 = gText_TheBardsSong2,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_FAN_CLUB,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW_SHOW_PERSON,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Interview,
|
|
|
|
.instructionsText1 = gText_FindWordsThatDescribeYour,
|
|
|
|
.instructionsText2 = gText_FeelingsRightNow,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_TRENDY_PHRASE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_COMBINE_TWO_WORDS,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_WhatsHipAndHappening,
|
|
|
|
.instructionsText1 = gText_CombineTwoWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndMakeATrendySaying,
|
|
|
|
.confirmText1 = gText_TheTrendySaying,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_QUIZ_QUESTION,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 5,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_QUIZ_QUESTION,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = TRUE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = NULL,
|
|
|
|
.instructionsText1 = gText_AfterYouHaveReadTheQuiz,
|
|
|
|
.instructionsText2 = gText_QuestionPressTheAButton,
|
|
|
|
.confirmText1 = NULL,
|
|
|
|
.confirmText2 = NULL,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_QUIZ_ANSWER,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_QUIZ_ANSWER,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = TRUE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_TheQuizAnswerIs,
|
|
|
|
.instructionsText1 = gText_OutOfTheListedChoices,
|
|
|
|
.instructionsText2 = gText_SelectTheAnswerToTheQuiz,
|
|
|
|
.confirmText1 = gText_TheAnswerColon,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_QUIZ_SET_QUESTION,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 5,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_QUIZ_SET_QUESTION,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = TRUE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = NULL,
|
|
|
|
.instructionsText1 = gText_CombineNineWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndCreateAQuiz,
|
|
|
|
.confirmText1 = gText_IsThisQuizOK,
|
|
|
|
.confirmText2 = NULL,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_QUIZ_SET_ANSWER,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_QUIZ_ANSWER,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = TRUE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_TheQuizAnswerIs,
|
|
|
|
.instructionsText1 = gText_PickAWordOrPhraseAnd,
|
|
|
|
.instructionsText2 = gText_SetTheQuizAnswer,
|
|
|
|
.confirmText1 = gText_IsThisQuizOK,
|
|
|
|
.confirmText2 = NULL,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BARD_SONG,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_TheBardsSong,
|
|
|
|
.instructionsText1 = gText_ChangeJustOneWordOrPhrase,
|
|
|
|
.instructionsText2 = gText_AndImproveTheBardsSong,
|
|
|
|
.confirmText1 = gText_TheBardsSong2,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_APPRENTICE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x3,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_ApprenticesPhrase,
|
|
|
|
.instructionsText1 = gText_FindWordsWhichFit,
|
|
|
|
.instructionsText2 = gText_TheTrainersImage,
|
|
|
|
.confirmText1 = gText_ApprenticePhrase,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_GOOD_SAYING,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_COMBINE_TWO_WORDS,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_GoodSaying,
|
|
|
|
.instructionsText1 = gText_CombineTwoWordsOrPhrases2,
|
|
|
|
.instructionsText2 = gText_ToTeachHerAGoodSaying,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_GABBY_AND_TY,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW_SHOW_PERSON,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Interview,
|
|
|
|
.instructionsText1 = gText_FindWordsThatDescribeYour,
|
|
|
|
.instructionsText2 = gText_FeelingsRightNow,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW_SHOW_PERSON,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Interview,
|
|
|
|
.instructionsText1 = gText_FindWordsThatDescribeYour,
|
|
|
|
.instructionsText2 = gText_FeelingsRightNow,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_CONTEST_INTERVIEW,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW_SHOW_PERSON,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Interview,
|
|
|
|
.instructionsText1 = gText_FindWordsThatDescribeYour,
|
|
|
|
.instructionsText2 = gText_FeelingsRightNow,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_FAN_QUESTION,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 1,
|
|
|
|
.numRows = 1,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_INTERVIEW_SHOW_PERSON,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_FansQuestion,
|
|
|
|
.instructionsText1 = gText_FindWordsWhichFit,
|
|
|
|
.instructionsText2 = gText_TheTrainersImage,
|
|
|
|
.confirmText1 = gText_TheImage,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
.type = EASY_CHAT_TYPE_QUESTIONNAIRE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.numColumns = 2,
|
|
|
|
.numRows = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.frameId = FRAMEID_GENERAL_2x2,
|
2019-02-27 19:45:31 +01:00
|
|
|
.fourFooterOptions = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.titleText = gText_Questionnaire,
|
|
|
|
.instructionsText1 = gText_CombineFourWordsOrPhrases,
|
|
|
|
.instructionsText2 = gText_AndFillOutTheQuestionnaire,
|
|
|
|
.confirmText1 = gText_TheAnswer,
|
|
|
|
.confirmText2 = gText_IsAsShownOkay,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// IDs are used indirectly as indexes into gEasyChatWordsByLetterPointers
|
|
|
|
// 0 is 'Others', 1-26 are the letters A-Z
|
|
|
|
// This array maps the group IDs to the alphabet keyboard
|
|
|
|
static const u8 sAlphabetGroupIdMap[NUM_ALPHABET_ROWS][NUM_ALPHABET_COLUMNS] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{ 1, 2, 3, 4, 5, 6, 0},
|
|
|
|
{ 7, 8, 9, 10, 11, 12, 0},
|
|
|
|
{13, 14, 15, 16, 17, 18, 19},
|
|
|
|
{20, 21, 22, 23, 24, 25, 26},
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sMysteryGiftPhrase[NUM_QUESTIONNAIRE_WORDS] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
EC_WORD_LINK,
|
|
|
|
EC_WORD_TOGETHER,
|
|
|
|
EC_WORD_WITH,
|
|
|
|
EC_WORD_ALL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u16 sBerryMasterWifePhrases[][2] = {
|
2019-11-06 20:06:06 +01:00
|
|
|
[PHRASE_GREAT_BATTLE - 1] = {EC_WORD_GREAT, EC_WORD_BATTLE},
|
|
|
|
[PHRASE_CHALLENGE_CONTEST - 1] = {EC_WORD_CHALLENGE, EC_WORD_CONTEST},
|
|
|
|
[PHRASE_OVERWHELMING_LATIAS - 1] = {EC_WORD_OVERWHELMING, EC_POKEMON(LATIAS)},
|
|
|
|
[PHRASE_COOL_LATIOS - 1] = {EC_WORD_COOL, EC_POKEMON(LATIOS)},
|
|
|
|
[PHRASE_SUPER_HUSTLE - 1] = {EC_WORD_SUPER, EC_WORD_HUSTLE},
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sTriangleCursor_Pal[] = INCBIN_U16("graphics/easy_chat/triangle_cursor.gbapal");
|
|
|
|
static const u32 sTriangleCursor_Gfx[] = INCBIN_U32("graphics/easy_chat/triangle_cursor.4bpp");
|
|
|
|
static const u32 sScrollIndicator_Gfx[] = INCBIN_U32("graphics/easy_chat/scroll_indicator.4bpp");
|
|
|
|
static const u32 sStartSelectButtons_Gfx[] = INCBIN_U32("graphics/easy_chat/start_select_buttons.4bpp");
|
2021-03-31 22:56:10 +02:00
|
|
|
// In Ruby/Sapphire Easy Chat screens had a black background, and when the player & interviewer were present
|
|
|
|
// on screen the interview_frame gfx was shown behind them.
|
|
|
|
// In Emerald all Easy Chat screens have a filled background, so these gfx go unused
|
|
|
|
static const u16 sRSInterviewFrame_Pal[] = INCBIN_U16("graphics/easy_chat/interview_frame.gbapal");
|
|
|
|
static const u32 sRSInterviewFrame_Gfx[] = INCBIN_U32("graphics/easy_chat/interview_frame.4bpp.lz");
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sTextInputFrameOrange_Pal[] = INCBIN_U16("graphics/easy_chat/text_input_frame_orange.gbapal");
|
|
|
|
static const u16 sTextInputFrameGreen_Pal[] = INCBIN_U16("graphics/easy_chat/text_input_frame_green.gbapal");
|
|
|
|
static const u32 sTextInputFrame_Gfx[] = INCBIN_U32("graphics/easy_chat/text_input_frame.4bpp.lz");
|
2021-03-31 22:56:10 +02:00
|
|
|
static const u16 sTitleText_Pal[] = INCBIN_U16("graphics/easy_chat/title_text.gbapal");
|
|
|
|
static const u16 sText_Pal[] = INCBIN_U16("graphics/easy_chat/text.gbapal");
|
2019-02-26 18:24:12 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static const struct EasyChatPhraseFrameDimensions sPhraseFrameDimensions[] = {
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_GENERAL_2x2] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 4,
|
|
|
|
.width = 24,
|
|
|
|
.height = 4,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_GENERAL_2x3] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 3,
|
|
|
|
.width = 24,
|
|
|
|
.height = 6,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_MAIL] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 0,
|
|
|
|
.width = 24,
|
|
|
|
.height = 10,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_COMBINE_TWO_WORDS] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 5,
|
|
|
|
.width = 24,
|
|
|
|
.height = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_INTERVIEW_SHOW_PERSON] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 16,
|
|
|
|
.top = 5,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_INTERVIEW] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 4,
|
|
|
|
.width = 24,
|
|
|
|
.height = 4,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_NORMAL,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_QUIZ_ANSWER] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 9,
|
|
|
|
.top = 4,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_QUIZ,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_QUIZ_QUESTION] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 5,
|
|
|
|
.top = 3,
|
2021-02-22 18:12:35 +01:00
|
|
|
.width = 20,
|
2019-02-27 19:45:31 +01:00
|
|
|
.height = 10,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = NUM_FOOTER_TYPES,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
2021-02-22 18:12:35 +01:00
|
|
|
[FRAMEID_QUIZ_SET_QUESTION] = {
|
2019-02-27 19:45:31 +01:00
|
|
|
.left = 3,
|
|
|
|
.top = 0,
|
|
|
|
.width = 24,
|
|
|
|
.height = 10,
|
2021-02-22 18:12:35 +01:00
|
|
|
.footerId = FOOTER_ANSWER,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct BgTemplate sEasyChatBgTemplates[] = {
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 28,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 3,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0x80,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 3,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct WindowTemplate sEasyChatWindowTemplates[] = {
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.tilemapLeft = 6,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 18,
|
|
|
|
.height = 2,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 10,
|
2019-02-26 18:24:12 +01:00
|
|
|
.baseBlock = 0x10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 3,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 24,
|
|
|
|
.height = 4,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 15,
|
2019-02-26 18:24:12 +01:00
|
|
|
.baseBlock = 0xA,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 28,
|
|
|
|
.height = 32,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 3,
|
2019-02-26 18:24:12 +01:00
|
|
|
.baseBlock = 0,
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct WindowTemplate sEasyChatYesNoWindowTemplate = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 22,
|
|
|
|
.tilemapTop = 9,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 15,
|
2019-02-26 18:24:12 +01:00
|
|
|
.baseBlock = 0x6A,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sText_Clear17[] = _("{CLEAR 17}");
|
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
static const u8 *const sEasyChatKeyboardAlphabet[NUM_ALPHABET_ROWS] =
|
2019-09-30 06:09:29 +02:00
|
|
|
{
|
|
|
|
gText_EasyChatKeyboard_ABCDEFothers,
|
|
|
|
gText_EasyChatKeyboard_GHIJKL,
|
|
|
|
gText_EasyChatKeyboard_MNOPQRS,
|
|
|
|
gText_EasyChatKeyboard_TUVWXYZ,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpriteSheet sSpriteSheets[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = sTriangleCursor_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = GFXTAG_TRIANGLE_CURSOR
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = sScrollIndicator_Gfx,
|
|
|
|
.size = 0x100,
|
|
|
|
.tag = GFXTAG_SCROLL_INDICATOR
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = sStartSelectButtons_Gfx,
|
|
|
|
.size = 0x100,
|
|
|
|
.tag = GFXTAG_START_SELECT_BUTTONS
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpritePalette sSpritePalettes[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = sTriangleCursor_Pal,
|
|
|
|
.tag = PALTAG_TRIANGLE_CURSOR,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = gEasyChatRectangleCursor_Pal,
|
|
|
|
.tag = PALTAG_RECTANGLE_CURSOR,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = gEasyChatButtonWindow_Pal,
|
|
|
|
.tag = PALTAG_MISC_UI, // The palette is generated from the button window but used for various parts of the UI
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-03-31 22:56:10 +02:00
|
|
|
.data = sRSInterviewFrame_Pal,
|
|
|
|
.tag = PALTAG_RS_INTERVIEW_FRAME,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct CompressedSpriteSheet sCompressedSpriteSheets[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
{
|
2021-03-31 22:56:10 +02:00
|
|
|
.data = sRSInterviewFrame_Gfx,
|
2021-02-22 18:12:35 +01:00
|
|
|
.size = 0x800,
|
2021-03-31 22:56:10 +02:00
|
|
|
.tag = GFXTAG_RS_INTERVIEW_FRAME,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = gEasyChatRectangleCursor_Gfx,
|
2019-02-26 18:24:12 +01:00
|
|
|
.size = 0x1000,
|
2021-02-22 18:12:35 +01:00
|
|
|
.tag = GFXTAG_RECTANGLE_CURSOR,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
.data = gEasyChatButtonWindow_Gfx,
|
|
|
|
.size = 0x800,
|
|
|
|
.tag = GFXTAG_BUTTON_WINDOW,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gEasyChatMode_Gfx,
|
|
|
|
.size = 0x1000,
|
2021-02-22 18:12:35 +01:00
|
|
|
.tag = GFXTAG_MODE_WINDOW,
|
2019-02-26 18:24:12 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u8 sAlphabetKeyboardColumnOffsets[NUM_ALPHABET_COLUMNS] = {0, 12, 24, 56, 68, 80, 92};
|
2019-02-26 18:24:12 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_TriangleCursor = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(8x8),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_TriangleCursor = {
|
|
|
|
.tileTag = PALTAG_TRIANGLE_CURSOR,
|
|
|
|
.paletteTag = GFXTAG_TRIANGLE_CURSOR,
|
|
|
|
.oam = &sOamData_TriangleCursor,
|
2019-02-26 18:24:12 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2021-02-22 18:12:35 +01:00
|
|
|
.callback = SpriteCB_Cursor,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_RectangleCursor = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x32),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_RectangleCursor_OnGroup[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_RectangleCursor_OnButton[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(32, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_RectangleCursor_OnOthers[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(64, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_RectangleCursor_OnLetter[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(96, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Each anim changes the width of the rectangle cursor to fit what it should be selecting
|
|
|
|
enum {
|
|
|
|
RECTCURSOR_ANIM_ON_GROUP,
|
|
|
|
RECTCURSOR_ANIM_ON_BUTTON,
|
|
|
|
RECTCURSOR_ANIM_ON_OTHERS,
|
|
|
|
RECTCURSOR_ANIM_ON_LETTER,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd *const sAnims_RectangleCursor[] = {
|
|
|
|
[RECTCURSOR_ANIM_ON_GROUP] = sAnim_RectangleCursor_OnGroup,
|
|
|
|
[RECTCURSOR_ANIM_ON_BUTTON] = sAnim_RectangleCursor_OnButton,
|
|
|
|
[RECTCURSOR_ANIM_ON_OTHERS] = sAnim_RectangleCursor_OnOthers,
|
|
|
|
[RECTCURSOR_ANIM_ON_LETTER] = sAnim_RectangleCursor_OnLetter,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_RectangleCursor = {
|
|
|
|
.tileTag = GFXTAG_RECTANGLE_CURSOR,
|
|
|
|
.paletteTag = PALTAG_RECTANGLE_CURSOR,
|
|
|
|
.oam = &sOamData_RectangleCursor,
|
|
|
|
.anims = sAnims_RectangleCursor,
|
2019-02-26 18:24:12 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2021-02-22 18:12:35 +01:00
|
|
|
.callback = SpriteCB_Cursor,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_ModeWindow = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x32),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_ModeWindow_Hidden[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(96, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_ModeWindow_ToGroup[] = {
|
|
|
|
ANIMCMD_FRAME(64, 4), // Transition frame
|
|
|
|
ANIMCMD_FRAME(32, 4), // 'Group' frame
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_ModeWindow_ToAlphabet[] = {
|
|
|
|
ANIMCMD_FRAME(64, 4), // Transition frame
|
|
|
|
ANIMCMD_FRAME(0, 4), // 'A-Z' frame
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_ModeWindow_ToHidden[] = {
|
|
|
|
ANIMCMD_FRAME(64, 4), // Transition frame
|
|
|
|
ANIMCMD_FRAME(96, 0), // Hidden frame
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_ModeWindow_Transition[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(64, 4),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
enum {
|
|
|
|
MODEWINDOW_ANIM_HIDDEN,
|
|
|
|
MODEWINDOW_ANIM_TO_GROUP,
|
|
|
|
MODEWINDOW_ANIM_TO_ALPHABET,
|
|
|
|
MODEWINDOW_ANIM_TO_HIDDEN,
|
|
|
|
MODEWINDOW_ANIM_TRANSITION,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd *const sAnims_ModeWindow[] = {
|
|
|
|
[MODEWINDOW_ANIM_HIDDEN] = sAnim_ModeWindow_Hidden,
|
|
|
|
[MODEWINDOW_ANIM_TO_GROUP] = sAnim_ModeWindow_ToGroup,
|
|
|
|
[MODEWINDOW_ANIM_TO_ALPHABET] = sAnim_ModeWindow_ToAlphabet,
|
|
|
|
[MODEWINDOW_ANIM_TO_HIDDEN] = sAnim_ModeWindow_ToHidden,
|
|
|
|
[MODEWINDOW_ANIM_TRANSITION] = sAnim_ModeWindow_Transition,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ModeWindow = {
|
|
|
|
.tileTag = GFXTAG_MODE_WINDOW,
|
|
|
|
.paletteTag = PALTAG_MISC_UI,
|
|
|
|
.oam = &sOamData_ModeWindow,
|
|
|
|
.anims = sAnims_ModeWindow,
|
2019-02-26 18:24:12 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_ButtonWindow = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ButtonWindow = {
|
|
|
|
.tileTag = GFXTAG_BUTTON_WINDOW,
|
|
|
|
.paletteTag = PALTAG_MISC_UI,
|
|
|
|
.oam = &sOamData_ButtonWindow,
|
2019-02-26 18:24:12 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_StartSelectButton = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(32x8),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct OamData sOamData_ScrollIndicator = {
|
2019-02-26 18:24:12 +01:00
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2022-07-30 03:27:39 +02:00
|
|
|
.mosaic = FALSE,
|
2019-02-26 18:24:12 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(16x16),
|
2019-02-26 18:24:12 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(16x16),
|
2019-02-26 18:24:12 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
2017-11-03 00:44:03 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_Frame0[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const union AnimCmd sAnim_Frame1[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
ANIMCMD_FRAME(4, 0),
|
|
|
|
ANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Frame0 is Start button, Frame1 is Select button, both are identical for the scroll indicators
|
|
|
|
static const union AnimCmd *const sAnims_TwoFrame[] = {
|
|
|
|
sAnim_Frame0,
|
|
|
|
sAnim_Frame1,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_StartSelectButton = {
|
|
|
|
.tileTag = GFXTAG_START_SELECT_BUTTONS,
|
|
|
|
.paletteTag = PALTAG_MISC_UI,
|
|
|
|
.oam = &sOamData_StartSelectButton,
|
|
|
|
.anims = sAnims_TwoFrame,
|
2019-02-26 18:24:12 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ScrollIndicator = {
|
|
|
|
.tileTag = GFXTAG_SCROLL_INDICATOR,
|
|
|
|
.paletteTag = PALTAG_MISC_UI,
|
|
|
|
.oam = &sOamData_ScrollIndicator,
|
|
|
|
.anims = sAnims_TwoFrame,
|
2019-02-26 18:24:12 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u8 sFooterOptionXOffsets[NUM_FOOTER_TYPES][4] = {
|
|
|
|
[FOOTER_NORMAL] = {16, 111, 196, 0},
|
|
|
|
[FOOTER_QUIZ] = {16, 78, 130, 160},
|
|
|
|
[FOOTER_ANSWER] = {16, 80, 134, 170},
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u8 *const sFooterTextOptions[NUM_FOOTER_TYPES][4] = {
|
|
|
|
[FOOTER_NORMAL] = {gText_DelAll, gText_Cancel5, gText_Ok2, NULL},
|
|
|
|
[FOOTER_QUIZ] = {gText_DelAll, gText_Cancel5, gText_Ok2, gText_Quiz},
|
|
|
|
[FOOTER_ANSWER] = {gText_DelAll, gText_Cancel5, gText_Ok2, gText_Answer},
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#include "data/easy_chat/easy_chat_groups.h"
|
|
|
|
#include "data/easy_chat/easy_chat_words_by_letter.h"
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u8 *const sEasyChatGroupNamePointers[EC_NUM_GROUPS] = {
|
|
|
|
[EC_GROUP_POKEMON] = gEasyChatGroupName_Pokemon,
|
|
|
|
[EC_GROUP_TRAINER] = gEasyChatGroupName_Trainer,
|
|
|
|
[EC_GROUP_STATUS] = gEasyChatGroupName_Status,
|
|
|
|
[EC_GROUP_BATTLE] = gEasyChatGroupName_Battle,
|
|
|
|
[EC_GROUP_GREETINGS] = gEasyChatGroupName_Greetings,
|
|
|
|
[EC_GROUP_PEOPLE] = gEasyChatGroupName_People,
|
|
|
|
[EC_GROUP_VOICES] = gEasyChatGroupName_Voices,
|
|
|
|
[EC_GROUP_SPEECH] = gEasyChatGroupName_Speech,
|
|
|
|
[EC_GROUP_ENDINGS] = gEasyChatGroupName_Endings,
|
|
|
|
[EC_GROUP_FEELINGS] = gEasyChatGroupName_Feelings,
|
|
|
|
[EC_GROUP_CONDITIONS] = gEasyChatGroupName_Conditions,
|
|
|
|
[EC_GROUP_ACTIONS] = gEasyChatGroupName_Actions,
|
|
|
|
[EC_GROUP_LIFESTYLE] = gEasyChatGroupName_Lifestyle,
|
|
|
|
[EC_GROUP_HOBBIES] = gEasyChatGroupName_Hobbies,
|
|
|
|
[EC_GROUP_TIME] = gEasyChatGroupName_Time,
|
|
|
|
[EC_GROUP_MISC] = gEasyChatGroupName_Misc,
|
|
|
|
[EC_GROUP_ADJECTIVES] = gEasyChatGroupName_Adjectives,
|
|
|
|
[EC_GROUP_EVENTS] = gEasyChatGroupName_Events,
|
|
|
|
[EC_GROUP_MOVE_1] = gEasyChatGroupName_Move1,
|
|
|
|
[EC_GROUP_MOVE_2] = gEasyChatGroupName_Move2,
|
|
|
|
[EC_GROUP_TRENDY_SAYING] = gEasyChatGroupName_TrendySaying,
|
|
|
|
[EC_GROUP_POKEMON_NATIONAL] = gEasyChatGroupName_Pokemon2,
|
2019-02-26 18:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sDefaultProfileWords[EASY_CHAT_BATTLE_WORDS_COUNT - 2] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
EC_WORD_I_AM,
|
|
|
|
EC_WORD_A,
|
|
|
|
EC_WORD_POKEMON,
|
|
|
|
EC_WORD_FRIEND,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sDefaultBattleStartWords[EASY_CHAT_BATTLE_WORDS_COUNT] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
EC_WORD_ARE,
|
|
|
|
EC_WORD_YOU,
|
|
|
|
EC_WORD_READY,
|
|
|
|
EC_WORD_QUES,
|
|
|
|
EC_WORD_HERE_I_COME,
|
|
|
|
EC_WORD_EXCL,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sDefaultBattleWonWords[EASY_CHAT_BATTLE_WORDS_COUNT] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
EC_WORD_YAY,
|
|
|
|
EC_WORD_YAY,
|
|
|
|
EC_WORD_EXCL_EXCL,
|
|
|
|
EC_WORD_I_VE,
|
|
|
|
EC_WORD_WON,
|
|
|
|
EC_WORD_EXCL_EXCL,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sDefaultBattleLostWords[EASY_CHAT_BATTLE_WORDS_COUNT] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
EC_WORD_TOO,
|
|
|
|
EC_WORD_BAD,
|
|
|
|
EC_WORD_ELLIPSIS,
|
|
|
|
EC_WORD_WE,
|
|
|
|
EC_WORD_LOST,
|
|
|
|
EC_WORD_ELLIPSIS,
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u16 sRestrictedWordSpecies[] = {
|
2019-02-26 18:24:12 +01:00
|
|
|
SPECIES_DEOXYS,
|
|
|
|
};
|
2017-09-25 14:53:25 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
// In addition to the task defines below, these two elements
|
|
|
|
// have their indexes used explicitly because they are 4-byte
|
|
|
|
// pointers, and occupy the next data element as well.
|
|
|
|
// SetWordTaskArg/GetWordTaskArg use these defines to
|
|
|
|
// read the pointer from the two elements
|
|
|
|
#define TASKIDX_WORDS 2
|
|
|
|
#define TASKIDX_EXIT_CALLBACK 4
|
|
|
|
|
|
|
|
#define tState data[0]
|
|
|
|
#define tType data[1]
|
|
|
|
#define tWords data[TASKIDX_WORDS] // Occupies 2 and 3
|
|
|
|
#define tExitCallback data[TASKIDX_EXIT_CALLBACK] // Occupies 4 and 5
|
|
|
|
#define tFuncId data[6]
|
|
|
|
#define tPersonType data[7]
|
|
|
|
|
|
|
|
void DoEasyChatScreen(u8 type, u16 *words, MainCallback exitCallback, u8 displayedPersonType)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
ResetTasks();
|
2021-02-22 18:12:35 +01:00
|
|
|
taskId = CreateTask(Task_InitEasyChatScreen, 0);
|
|
|
|
gTasks[taskId].tType = type;
|
|
|
|
gTasks[taskId].tPersonType = displayedPersonType;
|
|
|
|
SetWordTaskArg(taskId, TASKIDX_WORDS, (u32)words);
|
|
|
|
SetWordTaskArg(taskId, TASKIDX_EXIT_CALLBACK, (u32)exitCallback);
|
|
|
|
SetMainCallback2(CB2_EasyChatScreen);
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void CB2_EasyChatScreen(void)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void VBlankCB_EasyChatScreen(void)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
TransferPlttBuffer();
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void StartEasyChatScreen(u8 taskId, TaskFunc taskFunc)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].func = taskFunc;
|
2021-02-22 18:12:35 +01:00
|
|
|
gTasks[taskId].tState = MAINSTATE_FADE_IN;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void Task_InitEasyChatScreen(u8 taskId)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
if (!IsOverworldLinkActive())
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
while (InitEasyChatScreen(taskId));
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (InitEasyChatScreen(taskId) == TRUE)
|
2017-09-25 14:53:25 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
StartEasyChatScreen(taskId, Task_EasyChatScreen);
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// After loading, this is the 'main' Easy Chat task
|
|
|
|
static void Task_EasyChatScreen(u8 taskId)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 funcId;
|
2017-09-25 14:53:25 +02:00
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (tState)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_FADE_IN:
|
|
|
|
SetVBlankCallback(VBlankCB_EasyChatScreen);
|
2021-02-24 17:01:02 +01:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, 0);
|
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 16, 0, RGB_BLACK);
|
2021-02-22 18:12:35 +01:00
|
|
|
tState = MAINSTATE_WAIT_FADE_IN;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_HANDLE_INPUT:
|
|
|
|
funcId = HandleEasyChatInput();
|
|
|
|
if (IsFuncIdForQuizLadyScreen(funcId))
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Fade to Quiz Lady screen
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK);
|
2021-02-22 18:12:35 +01:00
|
|
|
tState = MAINSTATE_TO_QUIZ_LADY;
|
|
|
|
tFuncId = funcId;
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
else if (funcId == ECFUNC_EXIT)
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Fade and exit Easy Chat
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_BLACK);
|
2021-02-22 18:12:35 +01:00
|
|
|
tState = MAINSTATE_EXIT;
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
else if (funcId != ECFUNC_NONE)
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-02-22 18:12:35 +01:00
|
|
|
StartEasyChatFunction(funcId);
|
|
|
|
tState++; // MAINSTATE_RUN_FUNC
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_RUN_FUNC:
|
|
|
|
if (!RunEasyChatFunction())
|
|
|
|
tState = MAINSTATE_HANDLE_INPUT;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_TO_QUIZ_LADY:
|
2018-08-11 14:14:51 +02:00
|
|
|
if (!gPaletteFade.active)
|
2021-02-22 18:12:35 +01:00
|
|
|
EnterQuizLadyScreen(tFuncId);
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_EXIT:
|
2018-08-11 14:14:51 +02:00
|
|
|
if (!gPaletteFade.active)
|
2021-02-22 18:12:35 +01:00
|
|
|
ExitEasyChatScreen((MainCallback)GetWordTaskArg(taskId, TASKIDX_EXIT_CALLBACK));
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MAINSTATE_WAIT_FADE_IN:
|
2018-08-11 14:14:51 +02:00
|
|
|
if (!gPaletteFade.active)
|
2021-02-22 18:12:35 +01:00
|
|
|
tState = MAINSTATE_HANDLE_INPUT;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-25 23:22:51 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Returns TRUE if still initializing, FALSE when finished
|
|
|
|
// If an allocation fails it will switch to the exit callback
|
|
|
|
static bool8 InitEasyChatScreen(u8 taskId)
|
2017-09-25 23:22:51 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (tState)
|
2017-09-25 23:22:51 +02:00
|
|
|
{
|
2018-08-11 14:14:51 +02:00
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetPaletteFade();
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!InitEasyChatScreenWordData())
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Alloc failed, exit
|
|
|
|
ExitEasyChatScreen((MainCallback)GetWordTaskArg(taskId, TASKIDX_EXIT_CALLBACK));
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!InitEasyChatScreenStruct(tType, (u16 *)GetWordTaskArg(taskId, TASKIDX_WORDS), tPersonType))
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Alloc failed, exit
|
|
|
|
ExitEasyChatScreen((MainCallback)GetWordTaskArg(taskId, TASKIDX_EXIT_CALLBACK));
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!InitEasyChatScreenControl())
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Alloc failed, exit
|
|
|
|
ExitEasyChatScreen((MainCallback)GetWordTaskArg(taskId, TASKIDX_EXIT_CALLBACK));
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (LoadEasyChatScreen())
|
2018-08-11 14:14:51 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2017-09-25 23:22:51 +02:00
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
tState++;
|
2017-09-25 23:22:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-25 23:30:49 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ExitEasyChatScreen(MainCallback callback)
|
2017-09-25 23:30:49 +02:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
FreeEasyChatScreenControl();
|
|
|
|
FreeEasyChatScreenStruct();
|
|
|
|
FreeEasyChatScreenWordData();
|
2017-09-25 23:30:49 +02:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
SetMainCallback2(callback);
|
|
|
|
}
|
2017-11-03 00:26:14 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
void ShowEasyChatScreen(void)
|
2017-11-03 00:26:14 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u16 *words;
|
2018-08-11 14:14:51 +02:00
|
|
|
struct MauvilleManBard *bard;
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 displayedPersonType = EASY_CHAT_PERSON_DISPLAY_NONE;
|
2017-11-03 00:26:14 +01:00
|
|
|
switch (gSpecialVar_0x8004)
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_PROFILE:
|
|
|
|
words = gSaveBlock1Ptr->easyChatProfile;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_BATTLE_START:
|
|
|
|
words = gSaveBlock1Ptr->easyChatBattleStart;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_BATTLE_WON:
|
|
|
|
words = gSaveBlock1Ptr->easyChatBattleWon;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_BATTLE_LOST:
|
|
|
|
words = gSaveBlock1Ptr->easyChatBattleLost;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_MAIL:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = gSaveBlock1Ptr->mail[gSpecialVar_0x8005].words;
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_BARD_SONG:
|
2018-08-11 14:14:51 +02:00
|
|
|
bard = &gSaveBlock1Ptr->oldMan.bard;
|
2019-10-20 22:11:07 +02:00
|
|
|
for (i = 0; i < BARD_SONG_LENGTH; i ++)
|
2018-08-11 14:14:51 +02:00
|
|
|
bard->temporaryLyrics[i] = bard->songLyrics[i];
|
2019-02-27 19:45:31 +01:00
|
|
|
|
2018-08-11 14:14:51 +02:00
|
|
|
words = bard->temporaryLyrics;
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_INTERVIEW:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.words;
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = gSpecialVar_0x8006;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_FAN_CLUB:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words[gSpecialVar_0x8006];
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2021-04-25 23:22:45 +02:00
|
|
|
case EASY_CHAT_TYPE_DUMMY_SHOW:
|
|
|
|
words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].dummy.words;
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_TRENDY_PHRASE:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = (u16 *)gStringVar3;
|
2021-03-31 21:53:01 +02:00
|
|
|
words[0] = gSaveBlock1Ptr->dewfordTrends[0].words[0];
|
|
|
|
words[1] = gSaveBlock1Ptr->dewfordTrends[0].words[1];
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_GABBY_AND_TY:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = gSaveBlock1Ptr->gabbyAndTyData.quote;
|
2021-02-22 18:12:35 +01:00
|
|
|
*words = EC_EMPTY_WORD;
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_CONTEST_INTERVIEW:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.words[gSpecialVar_0x8006];
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW:
|
2022-06-14 15:18:55 +02:00
|
|
|
words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainerTower.words;
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_GOOD_SAYING:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = (u16 *)gStringVar3;
|
|
|
|
InitializeEasyChatWordArray(words, 2);
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_FAN_QUESTION:
|
2018-08-11 14:14:51 +02:00
|
|
|
words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanClubSpecial.words;
|
2021-02-22 18:12:35 +01:00
|
|
|
words[0] = EC_EMPTY_WORD;
|
2019-02-27 19:45:31 +01:00
|
|
|
displayedPersonType = EASY_CHAT_PERSON_BOY;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_ANSWER:
|
2019-08-06 02:37:09 +02:00
|
|
|
words = &gSaveBlock1Ptr->lilycoveLady.quiz.playerAnswer;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_QUESTION:
|
2018-08-11 14:14:51 +02:00
|
|
|
return;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_SET_QUESTION:
|
2019-08-04 16:15:50 +02:00
|
|
|
words = gSaveBlock1Ptr->lilycoveLady.quiz.question;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_SET_ANSWER:
|
2019-08-06 02:37:09 +02:00
|
|
|
words = &gSaveBlock1Ptr->lilycoveLady.quiz.correctAnswer;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_APPRENTICE:
|
2019-11-19 17:36:38 +01:00
|
|
|
words = gSaveBlock2Ptr->apprentices[0].speechWon;
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUESTIONNAIRE:
|
2021-02-22 18:12:35 +01:00
|
|
|
words = GetQuestionnaireWordsPtr();
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2017-11-03 00:26:14 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2019-02-27 19:45:31 +01:00
|
|
|
DoEasyChatScreen(gSpecialVar_0x8004, words, CB2_ReturnToFieldContinueScript, displayedPersonType);
|
2017-11-03 00:26:14 +01:00
|
|
|
}
|
2017-09-26 01:57:44 +02:00
|
|
|
|
2019-08-06 19:52:10 +02:00
|
|
|
static void CB2_QuizLadyQuestion(void)
|
2017-11-03 00:34:19 +01:00
|
|
|
{
|
|
|
|
LilycoveLady *lilycoveLady;
|
|
|
|
|
|
|
|
UpdatePaletteFade();
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
2018-08-11 14:14:51 +02:00
|
|
|
case 0:
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2018-08-11 14:14:51 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
|
2021-02-22 18:12:35 +01:00
|
|
|
lilycoveLady->quiz.playerAnswer = EC_EMPTY_WORD;
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2019-02-27 19:45:31 +01:00
|
|
|
DoQuizQuestionEasyChatScreen();
|
2018-08-11 14:14:51 +02:00
|
|
|
}
|
|
|
|
return;
|
2017-11-03 00:34:19 +01:00
|
|
|
}
|
|
|
|
gMain.state ++;
|
|
|
|
}
|
|
|
|
|
2019-08-06 19:52:10 +02:00
|
|
|
void QuizLadyShowQuizQuestion(void)
|
2017-11-03 00:34:19 +01:00
|
|
|
{
|
2019-08-06 19:52:10 +02:00
|
|
|
SetMainCallback2(CB2_QuizLadyQuestion);
|
2017-11-03 00:34:19 +01:00
|
|
|
}
|
2017-11-03 00:44:03 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int GetQuizLadyScreenByFuncId(u16 funcId)
|
2017-11-03 00:44:03 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sQuizLadyEasyChatScreens); i ++)
|
2017-11-03 00:44:03 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (funcId == sQuizLadyEasyChatScreens[i].funcId)
|
2017-11-03 00:44:03 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 IsFuncIdForQuizLadyScreen(u16 funcId)
|
2017-11-03 00:44:03 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return GetQuizLadyScreenByFuncId(funcId) == -1 ? FALSE : TRUE;
|
2017-11-03 00:44:03 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void EnterQuizLadyScreen(u16 funcId)
|
2017-11-03 00:44:03 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
i = GetQuizLadyScreenByFuncId(funcId);
|
2017-11-03 00:44:03 +01:00
|
|
|
ResetTasks();
|
2021-02-22 18:12:35 +01:00
|
|
|
ExitEasyChatScreen(sQuizLadyEasyChatScreens[i].callback);
|
2017-11-03 00:44:03 +01:00
|
|
|
}
|
2017-11-03 00:48:43 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static void DoQuizAnswerEasyChatScreen(void)
|
2017-11-03 00:48:43 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
DoEasyChatScreen(
|
|
|
|
EASY_CHAT_TYPE_QUIZ_ANSWER,
|
2019-08-06 02:37:09 +02:00
|
|
|
&gSaveBlock1Ptr->lilycoveLady.quiz.playerAnswer,
|
2019-02-27 19:45:31 +01:00
|
|
|
CB2_ReturnToFieldContinueScript,
|
|
|
|
EASY_CHAT_PERSON_DISPLAY_NONE);
|
2017-11-03 00:48:43 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static void DoQuizQuestionEasyChatScreen(void)
|
2017-11-03 00:48:43 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
DoEasyChatScreen(EASY_CHAT_TYPE_QUIZ_QUESTION,
|
2019-08-04 16:15:50 +02:00
|
|
|
gSaveBlock1Ptr->lilycoveLady.quiz.question,
|
2019-02-27 19:45:31 +01:00
|
|
|
CB2_ReturnToFieldContinueScript,
|
|
|
|
EASY_CHAT_PERSON_DISPLAY_NONE);
|
2017-11-03 00:48:43 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static void DoQuizSetAnswerEasyChatScreen(void)
|
2017-11-03 00:48:43 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
DoEasyChatScreen(EASY_CHAT_TYPE_QUIZ_SET_ANSWER,
|
2019-08-06 02:37:09 +02:00
|
|
|
&gSaveBlock1Ptr->lilycoveLady.quiz.correctAnswer,
|
2019-02-27 19:45:31 +01:00
|
|
|
CB2_ReturnToFieldContinueScript,
|
|
|
|
EASY_CHAT_PERSON_DISPLAY_NONE);
|
2017-11-03 00:48:43 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static void DoQuizSetQuestionEasyChatScreen(void)
|
2017-11-03 00:48:43 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
DoEasyChatScreen(EASY_CHAT_TYPE_QUIZ_SET_QUESTION,
|
2019-08-04 16:15:50 +02:00
|
|
|
gSaveBlock1Ptr->lilycoveLady.quiz.question,
|
2019-02-27 19:45:31 +01:00
|
|
|
CB2_ReturnToFieldContinueScript,
|
|
|
|
EASY_CHAT_PERSON_DISPLAY_NONE);
|
2017-11-03 00:48:43 +01:00
|
|
|
}
|
2017-11-03 01:37:03 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 InitEasyChatScreenStruct(u8 type, u16 *words, u8 displayedPersonType)
|
2017-11-03 01:37:03 +01:00
|
|
|
{
|
2019-02-22 00:40:20 +01:00
|
|
|
u8 templateId;
|
2017-11-03 01:37:03 +01:00
|
|
|
int i;
|
2018-08-11 14:14:51 +02:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen = malloc(sizeof(*sEasyChatScreen));
|
|
|
|
if (sEasyChatScreen == NULL)
|
2017-11-03 01:37:03 +01:00
|
|
|
return FALSE;
|
2019-02-27 19:45:31 +01:00
|
|
|
|
|
|
|
sEasyChatScreen->type = type;
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->savedPhrase = words;
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn = 0;
|
|
|
|
sEasyChatScreen->mainCursorRow = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inAlphabetMode = FALSE;
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->displayedPersonType = displayedPersonType;
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->unused = 0;
|
2019-02-27 19:45:31 +01:00
|
|
|
templateId = GetEachChatScreenTemplateId(type);
|
|
|
|
if (type == EASY_CHAT_TYPE_QUIZ_QUESTION)
|
2017-11-03 01:37:03 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
GetQuizTitle(sEasyChatScreen->quizTitle);
|
|
|
|
sEasyChatScreen->titleText = sEasyChatScreen->quizTitle;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_QUIZ_QUESTION;
|
2017-11-03 01:37:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_PHRASE;
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->titleText = sEasyChatScreenTemplates[templateId].titleText;
|
2017-11-03 01:37:03 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
|
|
|
|
sEasyChatScreen->numColumns = sEasyChatScreenTemplates[templateId].numColumns;
|
|
|
|
sEasyChatScreen->numRows = sEasyChatScreenTemplates[templateId].numRows;
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->maxWords = sEasyChatScreen->numColumns * sEasyChatScreen->numRows;
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->templateId = templateId;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->maxWords > ARRAY_COUNT(sEasyChatScreen->currentPhrase))
|
|
|
|
sEasyChatScreen->maxWords = ARRAY_COUNT(sEasyChatScreen->currentPhrase);
|
2019-02-27 19:45:31 +01:00
|
|
|
|
2017-11-03 01:37:03 +01:00
|
|
|
if (words != NULL)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Phrase starts with words filled in, copy to current phrase
|
|
|
|
CpuCopy16(words, sEasyChatScreen->currentPhrase, sEasyChatScreen->maxWords * sizeof(u16));
|
2017-11-03 01:37:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Phrase starts with no words, fill with empty words and save
|
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i ++)
|
|
|
|
sEasyChatScreen->currentPhrase[i] = EC_EMPTY_WORD;
|
2019-02-27 19:45:31 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->savedPhrase = sEasyChatScreen->currentPhrase;
|
2017-11-03 01:37:03 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardLastRow = (GetNumUnlockedEasyChatGroups() - 1) / 2 + 1;
|
2017-11-03 01:37:03 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-11-03 01:51:13 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void FreeEasyChatScreenStruct(void)
|
2017-11-03 01:51:13 +01:00
|
|
|
{
|
2022-06-03 16:42:53 +02:00
|
|
|
TRY_FREE_AND_SET_NULL(sEasyChatScreen);
|
2017-11-03 01:51:13 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Returns the function ID of the action to take as a result of player's input.
|
|
|
|
// If no action is needed, returns ECFUNC_NONE
|
|
|
|
static u16 HandleEasyChatInput(void)
|
|
|
|
{
|
|
|
|
switch (sEasyChatScreen->inputState)
|
|
|
|
{
|
|
|
|
case INPUTSTATE_PHRASE:
|
|
|
|
return HandleEasyChatInput_Phrase();
|
|
|
|
case INPUTSTATE_MAIN_SCREEN_BUTTONS:
|
|
|
|
return HandleEasyChatInput_MainScreenButtons();
|
|
|
|
case INPUTSTATE_KEYBOARD:
|
|
|
|
return HandleEasyChatInput_Keyboard();
|
|
|
|
case INPUTSTATE_WORD_SELECT:
|
|
|
|
return HandleEasyChatInput_WordSelect();
|
|
|
|
case INPUTSTATE_EXIT_PROMPT:
|
|
|
|
return HandleEasyChatInput_ExitPrompt();
|
|
|
|
case INPUTSTATE_DELETE_ALL_YES_NO:
|
|
|
|
return HandleEasyChatInput_DeleteAllYesNo();
|
|
|
|
case INPUTSTATE_CONFIRM_WORDS_YES_NO:
|
|
|
|
return HandleEasyChatInput_ConfirmWordsYesNo();
|
|
|
|
case INPUTSTATE_QUIZ_QUESTION:
|
|
|
|
return HandleEasyChatInput_QuizQuestion();
|
|
|
|
case INPUTSTATE_WAIT_FOR_MSG:
|
|
|
|
return HandleEasyChatInput_WaitForMsg();
|
|
|
|
case INPUTSTATE_START_CONFIRM_LYRICS:
|
|
|
|
return HandleEasyChatInput_StartConfirmLyrics();
|
|
|
|
case INPUTSTATE_CONFIRM_LYRICS_YES_NO:
|
|
|
|
return HandleEasyChatInput_ConfirmLyricsYesNo();
|
|
|
|
}
|
|
|
|
return ECFUNC_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool32 IsCurrentFrame2x5(void)
|
2017-11-03 01:54:13 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (GetEasyChatScreenFrameId())
|
2017-11-03 01:54:13 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case FRAMEID_MAIL:
|
|
|
|
case FRAMEID_QUIZ_QUESTION:
|
|
|
|
case FRAMEID_QUIZ_SET_QUESTION:
|
2018-08-11 14:14:51 +02:00
|
|
|
return TRUE;
|
2017-11-03 01:54:13 +01:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-11-25 19:19:06 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Handles main screen input while cursor is on a word in the phrase
|
|
|
|
static u16 HandleEasyChatInput_Phrase(void)
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2019-02-25 22:20:00 +01:00
|
|
|
do
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
ClearUnusedField();
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_KEYBOARD;
|
|
|
|
sEasyChatScreen->keyboardColumn = 0;
|
|
|
|
sEasyChatScreen->keyboardRow = 0;
|
|
|
|
sEasyChatScreen->keyboardScrollOffset = 0;
|
|
|
|
return ECFUNC_OPEN_KEYBOARD;
|
2019-02-25 22:20:00 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return StartConfirmExitPrompt();
|
2019-02-25 22:20:00 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(START_BUTTON))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return TryConfirmWords();
|
2019-02-25 22:20:00 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorRow--;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_LEFT))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn--;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorRow++;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn++;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-25 22:20:00 +01:00
|
|
|
} while (0);
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Handle D-Pad input
|
|
|
|
|
|
|
|
// Wrap row
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorRow < 0)
|
|
|
|
sEasyChatScreen->mainCursorRow = sEasyChatScreenTemplates[sEasyChatScreen->templateId].numRows;
|
|
|
|
if (sEasyChatScreen->mainCursorRow > sEasyChatScreenTemplates[sEasyChatScreen->templateId].numRows)
|
|
|
|
sEasyChatScreen->mainCursorRow = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorRow == sEasyChatScreenTemplates[sEasyChatScreen->templateId].numRows)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Moved onto bottom row (buttons)
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorColumn > 2)
|
|
|
|
sEasyChatScreen->mainCursorColumn = 2;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_MAIN_SCREEN_BUTTONS;
|
|
|
|
return ECFUNC_UPDATE_MAIN_CURSOR_ON_BUTTONS;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Wrap column
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorColumn < 0)
|
|
|
|
sEasyChatScreen->mainCursorColumn = sEasyChatScreenTemplates[sEasyChatScreen->templateId].numColumns - 1;
|
|
|
|
if (sEasyChatScreen->mainCursorColumn >= sEasyChatScreenTemplates[sEasyChatScreen->templateId].numColumns)
|
|
|
|
sEasyChatScreen->mainCursorColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// All 2x5 phrases are only 9 words long, exclude the bottom right (10th) position
|
|
|
|
if (IsCurrentFrame2x5() && sEasyChatScreen->mainCursorColumn == 1 && sEasyChatScreen->mainCursorRow == 4)
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_MAIN_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Handles main screen input while cursor is below the phrase on one of the buttons, e.g. Del. All or Cancel
|
|
|
|
static u16 HandleEasyChatInput_MainScreenButtons(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-25 22:20:00 +01:00
|
|
|
do
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (sEasyChatScreen->mainCursorColumn)
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case 0: // Del. All button
|
|
|
|
return DoDeleteAllButton();
|
|
|
|
case 1: // Cancel button
|
|
|
|
return StartConfirmExitPrompt();
|
|
|
|
case 2: // OK button
|
|
|
|
return TryConfirmWords();
|
|
|
|
case 3: // Quiz/Answer button
|
|
|
|
return DoQuizButton();
|
2019-02-25 22:20:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return StartConfirmExitPrompt();
|
2019-02-25 22:20:00 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(START_BUTTON))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return TryConfirmWords();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorRow--;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_LEFT))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn--;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorRow = 0;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT))
|
2019-02-25 22:20:00 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn++;
|
2019-02-25 22:20:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-25 22:20:00 +01:00
|
|
|
} while (0);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorRow == sEasyChatScreenTemplates[sEasyChatScreen->templateId].numRows)
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
int numFooterColumns = FooterHasFourOptions() ? 4 : 3;
|
|
|
|
if (sEasyChatScreen->mainCursorColumn < 0)
|
|
|
|
sEasyChatScreen->mainCursorColumn = numFooterColumns - 1;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorColumn >= numFooterColumns)
|
|
|
|
sEasyChatScreen->mainCursorColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_MAIN_CURSOR_ON_BUTTONS;
|
2017-11-25 19:19:06 +01:00
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->mainCursorColumn >= sEasyChatScreenTemplates[sEasyChatScreen->templateId].numColumns)
|
|
|
|
sEasyChatScreen->mainCursorColumn = sEasyChatScreenTemplates[sEasyChatScreen->templateId].numColumns - 1;
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// All 2x5 phrases are only 9 words long, exclude the bottom right (10th) position
|
|
|
|
if (IsCurrentFrame2x5() && sEasyChatScreen->mainCursorColumn == 1 && sEasyChatScreen->mainCursorRow == 4)
|
2019-02-27 19:45:31 +01:00
|
|
|
sEasyChatScreen->mainCursorColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_PHRASE;
|
|
|
|
return ECFUNC_UPDATE_MAIN_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_Keyboard(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return ExitKeyboardToMainScreen();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->keyboardColumn != -1)
|
|
|
|
return SelectKeyboardGroup();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Cursor is in button window
|
|
|
|
switch (sEasyChatScreen->keyboardRow)
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case 0: // Mode button
|
|
|
|
return StartSwitchKeyboardMode();
|
|
|
|
case 1: // Delete button
|
|
|
|
return DeleteSelectedWord();
|
|
|
|
case 2: // Cancel button
|
|
|
|
return ExitKeyboardToMainScreen();
|
2017-11-25 19:19:06 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return StartSwitchKeyboardMode();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor(INPUT_UP);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_DOWN))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor(INPUT_DOWN);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_LEFT))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor(INPUT_LEFT);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_RIGHT))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor(INPUT_RIGHT);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Input handling for the lower window after a word group has been selected
|
|
|
|
static u16 HandleEasyChatInput_WordSelect(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_KEYBOARD;
|
|
|
|
return ECFUNC_RETURN_TO_KEYBOARD;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return SelectNewWord();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(START_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_START);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_SELECT);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_UP);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_DOWN))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_DOWN);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_LEFT))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_LEFT);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_RIGHT))
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveWordSelectCursor(INPUT_RIGHT);
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_ExitPrompt(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MENU_B_PRESSED:
|
|
|
|
case 1: // No (Continue)
|
|
|
|
sEasyChatScreen->inputState = GetEasyChatBackupState();
|
|
|
|
return ECFUNC_CLOSE_PROMPT;
|
|
|
|
case 0: // Yes (Exit)
|
2019-02-22 00:40:20 +01:00
|
|
|
gSpecialVar_Result = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_QUESTION
|
|
|
|
|| sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_ANSWER)
|
|
|
|
SaveCurrentPhrase();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2017-11-25 19:19:06 +01:00
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_ConfirmWordsYesNo(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MENU_B_PRESSED:
|
2019-02-22 00:40:20 +01:00
|
|
|
case 1: // No
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = GetEasyChatBackupState();
|
|
|
|
return ECFUNC_CLOSE_PROMPT;
|
2019-02-22 00:40:20 +01:00
|
|
|
case 0: // Yes
|
2021-02-22 18:12:35 +01:00
|
|
|
SetSpecialEasyChatResult();
|
|
|
|
gSpecialVar_Result = GetEasyChatCompleted();
|
|
|
|
SaveCurrentPhrase();
|
|
|
|
return ECFUNC_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2017-11-25 19:19:06 +01:00
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_DeleteAllYesNo(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2017-11-25 19:19:06 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MENU_B_PRESSED:
|
2019-02-22 00:40:20 +01:00
|
|
|
case 1: // No
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_MAIN_SCREEN_BUTTONS;
|
|
|
|
return ECFUNC_CLOSE_PROMPT;
|
2019-02-22 00:40:20 +01:00
|
|
|
case 0: // Yes
|
2021-02-22 18:12:35 +01:00
|
|
|
ResetCurrentPhrase();
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_MAIN_SCREEN_BUTTONS;
|
|
|
|
return ECFUNC_CLOSE_PROMPT_AFTER_DELETE;
|
2019-02-22 00:40:20 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2017-11-25 19:19:06 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_QuizQuestion(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_QUIZ_ANSWER;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2021-02-22 18:12:35 +01:00
|
|
|
return StartConfirmExitPrompt();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// A message has been printed. Wait for player to
|
|
|
|
// press A or B, then return to previous state
|
|
|
|
static u16 HandleEasyChatInput_WaitForMsg(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = GetEasyChatBackupState();
|
|
|
|
return ECFUNC_CLOSE_PROMPT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Odd, could have been skipped. Just passes to HandleEasyChatInput_ConfirmLyricsYesNo
|
|
|
|
static u16 HandleEasyChatInput_StartConfirmLyrics(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_LYRICS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 HandleEasyChatInput_ConfirmLyricsYesNo(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MENU_B_PRESSED:
|
2019-02-22 00:40:20 +01:00
|
|
|
case 1: // No
|
2021-02-22 18:12:35 +01:00
|
|
|
ResetCurrentPhraseToSaved();
|
|
|
|
sEasyChatScreen->inputStateBackup = INPUTSTATE_PHRASE;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_SONG_TOO_SHORT;
|
2019-02-22 00:40:20 +01:00
|
|
|
case 0: // Yes
|
2021-02-22 18:12:35 +01:00
|
|
|
gSpecialVar_Result = GetEasyChatCompleted();
|
|
|
|
SaveCurrentPhrase();
|
|
|
|
return ECFUNC_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 StartConfirmExitPrompt(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_APPRENTICE
|
|
|
|
|| sEasyChatScreen->type == EASY_CHAT_TYPE_CONTEST_INTERVIEW)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_CANT_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_EXIT_PROMPT;
|
|
|
|
return ECFUNC_PROMPT_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int DoDeleteAllButton(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type != EASY_CHAT_TYPE_BARD_SONG)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Show Delete yes/no
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_DELETE_ALL_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_DELETE_ALL;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Cannot delete lyrics when setting Bard's song
|
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_CANT_DELETE_LYRICS;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 TryConfirmWords(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_QUESTION)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizQuestionEmpty())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_CREATE_QUIZ;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizAnswerEmpty())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_SELECT_ANSWER;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
else if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_ANSWER)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizAnswerEmpty())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_SELECT_ANSWER;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizQuestionEmpty())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_CREATE_QUIZ;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
else if (sEasyChatScreen->type == EASY_CHAT_TYPE_TRENDY_PHRASE
|
|
|
|
|| sEasyChatScreen->type == EASY_CHAT_TYPE_GOOD_SAYING)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!IsCurrentPhraseFull())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_COMBINE_TWO_WORDS;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
else if (sEasyChatScreen->type == EASY_CHAT_TYPE_APPRENTICE
|
|
|
|
|| sEasyChatScreen->type == EASY_CHAT_TYPE_CONTEST_INTERVIEW)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsCurrentPhraseEmpty())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WAIT_FOR_MSG;
|
|
|
|
return ECFUNC_MSG_CANT_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-27 19:45:31 +01:00
|
|
|
else if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUESTIONNAIRE)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsCurrentPhraseEmpty() == TRUE || !GetEasyChatCompleted())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_EXIT_PROMPT;
|
|
|
|
return ECFUNC_PROMPT_EXIT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_CONFIRM_WORDS_YES_NO;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int DoQuizButton(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputStateBackup = sEasyChatScreen->inputState;
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (sEasyChatScreen->type)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_ANSWER:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_QUIZ_QUESTION;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_SET_QUESTION:
|
2021-02-22 18:12:35 +01:00
|
|
|
SaveCurrentPhrase();
|
|
|
|
return ECFUNC_SET_QUIZ_ANSWER;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_SET_ANSWER:
|
2021-02-22 18:12:35 +01:00
|
|
|
SaveCurrentPhrase();
|
|
|
|
return ECFUNC_SET_QUIZ_QUESTION;
|
2019-02-22 00:40:20 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetEasyChatBackupState(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->inputStateBackup;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int SelectKeyboardGroup(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 numWords;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!sEasyChatScreen->inAlphabetMode)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 groupId = GetUnlockedEasyChatGroupId(GetSelectedGroupIndex());
|
|
|
|
SetSelectedWordGroup(FALSE, groupId);
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
SetSelectedWordGroup(TRUE, GetSelectedAlphabetGroupId());
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
numWords = GetNumWordsInSelectedGroup();
|
|
|
|
if (numWords == 0)
|
|
|
|
return ECFUNC_NONE;
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectLastRow = (numWords - 1) / 2;
|
|
|
|
sEasyChatScreen->wordSelectScrollOffset = 0;
|
|
|
|
sEasyChatScreen->wordSelectColumn = 0;
|
|
|
|
sEasyChatScreen->wordSelectRow = 0;
|
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_WORD_SELECT;
|
|
|
|
return ECFUNC_OPEN_WORD_SELECT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int ExitKeyboardToMainScreen(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_PHRASE;
|
|
|
|
return ECFUNC_CLOSE_KEYBOARD;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int StartSwitchKeyboardMode(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardColumn = 0;
|
|
|
|
sEasyChatScreen->keyboardRow = 0;
|
|
|
|
sEasyChatScreen->keyboardScrollOffset = 0;
|
|
|
|
if (!sEasyChatScreen->inAlphabetMode)
|
|
|
|
sEasyChatScreen->inAlphabetMode = TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inAlphabetMode = FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_SWITCH_KEYBOARD_MODE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int DeleteSelectedWord(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_BARD_SONG)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
SetSelectedWord(EC_EMPTY_WORD);
|
|
|
|
return ECFUNC_REPRINT_PHRASE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int SelectNewWord(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 easyChatWord = GetWordFromSelectedGroup(GetSelectedWordIndex());
|
|
|
|
if (DummyWordCheck(easyChatWord))
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Never reached. Would disallow selecting certain words
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
SetSelectedWord(easyChatWord);
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type != EASY_CHAT_TYPE_BARD_SONG)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_PHRASE;
|
|
|
|
return ECFUNC_CLOSE_WORD_SELECT;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->inputState = INPUTSTATE_START_CONFIRM_LYRICS;
|
|
|
|
return ECFUNC_PROMPT_CONFIRM_LYRICS;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SaveCurrentPhrase(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
|
|
|
sEasyChatScreen->savedPhrase[i] = sEasyChatScreen->currentPhrase[i];
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ResetCurrentPhrase(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
|
|
|
sEasyChatScreen->currentPhrase[i] = EC_EMPTY_WORD;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ResetCurrentPhraseToSaved(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
|
|
|
sEasyChatScreen->currentPhrase[i] = sEasyChatScreen->savedPhrase[i];
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetSelectedWord(u16 easyChatWord)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 index = GetWordIndexToReplace();
|
|
|
|
sEasyChatScreen->currentPhrase[index] = easyChatWord;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Compare current phrase to the original saved phrase
|
|
|
|
static bool8 DidPhraseChange(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->currentPhrase[i] != sEasyChatScreen->savedPhrase[i])
|
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// 'Completed' if the phrase was changed, or in the case of making a quiz, the question and answer were filled out
|
|
|
|
static bool32 GetEasyChatCompleted(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_QUESTION
|
|
|
|
|| sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_ANSWER)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizQuestionEmpty())
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsQuizAnswerEmpty())
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return DidPhraseChange();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 MoveKeyboardCursor(int input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->keyboardColumn != -1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!sEasyChatScreen->inAlphabetMode)
|
|
|
|
return MoveKeyboardCursor_GroupNames(input);
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor_Alphabet(input);
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return MoveKeyboardCursor_ButtonWindow(input);
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int MoveKeyboardCursor_GroupNames(u32 input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_UP:
|
|
|
|
if (sEasyChatScreen->keyboardRow != -sEasyChatScreen->keyboardScrollOffset)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->keyboardRow)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow--;
|
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardScrollOffset--;
|
|
|
|
return ECFUNC_GROUP_NAMES_SCROLL_UP;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_DOWN:
|
|
|
|
if (sEasyChatScreen->keyboardRow + sEasyChatScreen->keyboardScrollOffset < sEasyChatScreen->keyboardLastRow - 1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
int funcId;
|
|
|
|
if (sEasyChatScreen->keyboardRow < NUM_GROUP_NAME_ROWS - 1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow++;
|
|
|
|
funcId = ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardScrollOffset++;
|
|
|
|
funcId = ECFUNC_GROUP_NAMES_SCROLL_DOWN;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidKeyboardColumn();
|
|
|
|
return funcId;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_LEFT:
|
|
|
|
if (sEasyChatScreen->keyboardColumn)
|
|
|
|
sEasyChatScreen->keyboardColumn--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
SetKeyboardCursorInButtonWindow();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_RIGHT:
|
|
|
|
if (sEasyChatScreen->keyboardColumn < 1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardColumn++;
|
|
|
|
if (IsSelectedKeyboardIndexInvalid())
|
|
|
|
SetKeyboardCursorInButtonWindow();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
SetKeyboardCursorInButtonWindow();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int MoveKeyboardCursor_Alphabet(u32 input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_UP:
|
|
|
|
if (sEasyChatScreen->keyboardRow > 0)
|
|
|
|
sEasyChatScreen->keyboardRow--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow = NUM_ALPHABET_ROWS - 1;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidKeyboardColumn();
|
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_DOWN:
|
|
|
|
if (sEasyChatScreen->keyboardRow < NUM_ALPHABET_ROWS - 1)
|
|
|
|
sEasyChatScreen->keyboardRow++;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidKeyboardColumn();
|
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_RIGHT:
|
|
|
|
sEasyChatScreen->keyboardColumn++;
|
|
|
|
if (IsSelectedKeyboardIndexInvalid())
|
|
|
|
SetKeyboardCursorInButtonWindow();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_LEFT:
|
|
|
|
sEasyChatScreen->keyboardColumn--;
|
|
|
|
if (sEasyChatScreen->keyboardColumn < 0)
|
|
|
|
SetKeyboardCursorInButtonWindow();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int MoveKeyboardCursor_ButtonWindow(u32 input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_UP:
|
|
|
|
if (sEasyChatScreen->keyboardRow)
|
|
|
|
sEasyChatScreen->keyboardRow--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow = NUM_BUTTON_ROWS - 1;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_DOWN:
|
|
|
|
if (sEasyChatScreen->keyboardRow < NUM_BUTTON_ROWS - 1)
|
|
|
|
sEasyChatScreen->keyboardRow++;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardRow = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_LEFT:
|
|
|
|
sEasyChatScreen->keyboardRow++;
|
|
|
|
SetKeyboardCursorToLastColumn();
|
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
|
|
|
case INPUT_RIGHT:
|
|
|
|
sEasyChatScreen->keyboardColumn = 0;
|
|
|
|
sEasyChatScreen->keyboardRow++;
|
|
|
|
return ECFUNC_UPDATE_KEYBOARD_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetKeyboardCursorInButtonWindow(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardColumn = -1;
|
|
|
|
if (sEasyChatScreen->keyboardRow)
|
|
|
|
sEasyChatScreen->keyboardRow--;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetKeyboardCursorToLastColumn(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!sEasyChatScreen->inAlphabetMode)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardColumn = 1;
|
|
|
|
ReduceToValidKeyboardColumn();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->keyboardColumn = GetLastAlphabetColumn(sEasyChatScreen->keyboardRow);
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 MoveWordSelectCursor(u32 input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 funcId;
|
|
|
|
switch (input)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_UP:
|
|
|
|
if (sEasyChatScreen->wordSelectRow + sEasyChatScreen->wordSelectScrollOffset > 0)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->wordSelectRow > 0)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectRow--;
|
|
|
|
funcId = ECFUNC_UPDATE_WORD_SELECT_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectScrollOffset--;
|
|
|
|
funcId = ECFUNC_WORD_SELECT_SCROLL_UP;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidWordSelectColumn();
|
|
|
|
return funcId;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_DOWN:
|
|
|
|
if (sEasyChatScreen->wordSelectRow + sEasyChatScreen->wordSelectScrollOffset < sEasyChatScreen->wordSelectLastRow)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->wordSelectRow < NUM_WORD_SELECT_ROWS - 1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectRow++;
|
|
|
|
funcId = ECFUNC_UPDATE_WORD_SELECT_CURSOR;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectScrollOffset++;
|
|
|
|
funcId = ECFUNC_WORD_SELECT_SCROLL_DOWN;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidWordSelectColumn();
|
|
|
|
return funcId;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_LEFT:
|
|
|
|
if (sEasyChatScreen->wordSelectColumn > 0)
|
|
|
|
sEasyChatScreen->wordSelectColumn--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectColumn = 1;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidWordSelectColumn();
|
|
|
|
return ECFUNC_UPDATE_WORD_SELECT_CURSOR;
|
|
|
|
case INPUT_RIGHT:
|
|
|
|
if (sEasyChatScreen->wordSelectColumn < 1)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectColumn++;
|
|
|
|
if (IsSelectedWordIndexInvalid())
|
|
|
|
sEasyChatScreen->wordSelectColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectColumn = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_UPDATE_WORD_SELECT_CURSOR;
|
|
|
|
case INPUT_START:
|
|
|
|
// Page scroll up
|
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset >= NUM_WORD_SELECT_ROWS)
|
|
|
|
sEasyChatScreen->wordSelectScrollOffset -= NUM_WORD_SELECT_ROWS;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectScrollOffset = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_WORD_SELECT_PAGE_UP;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUT_SELECT:
|
|
|
|
// Page scroll down
|
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset <= sEasyChatScreen->wordSelectLastRow - NUM_WORD_SELECT_ROWS)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->wordSelectScrollOffset += NUM_WORD_SELECT_ROWS;
|
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset > sEasyChatScreen->wordSelectLastRow - NUM_WORD_SELECT_ROWS + 1)
|
|
|
|
sEasyChatScreen->wordSelectScrollOffset = sEasyChatScreen->wordSelectLastRow - NUM_WORD_SELECT_ROWS + 1;
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
ReduceToValidWordSelectColumn();
|
|
|
|
return ECFUNC_WORD_SELECT_PAGE_DOWN;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return ECFUNC_NONE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 GetWordIndexToReplace(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return (sEasyChatScreen->mainCursorRow * sEasyChatScreen->numColumns) + sEasyChatScreen->mainCursorColumn;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 GetSelectedGroupIndex(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return NUM_GROUP_NAME_COLUMNS * (sEasyChatScreen->keyboardRow + sEasyChatScreen->keyboardScrollOffset) + sEasyChatScreen->keyboardColumn;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int GetSelectedAlphabetGroupId(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
int column = (u8)sEasyChatScreen->keyboardColumn < NUM_ALPHABET_COLUMNS ? sEasyChatScreen->keyboardColumn : 0;
|
|
|
|
int row = (u8)sEasyChatScreen->keyboardRow < NUM_ALPHABET_ROWS ? sEasyChatScreen->keyboardRow : 0;
|
|
|
|
return sAlphabetGroupIdMap[row][column];
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 GetSelectedWordIndex(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return NUM_WORD_SELECT_COLUMNS * (sEasyChatScreen->wordSelectRow + sEasyChatScreen->wordSelectScrollOffset) + sEasyChatScreen->wordSelectColumn;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Get the index of the last column in the alphabet keyboard, depending on current row
|
|
|
|
static u8 GetLastAlphabetColumn(u8 row)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (row)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return NUM_ALPHABET_COLUMNS - 1;
|
2019-02-22 00:40:20 +01:00
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
return NUM_ALPHABET_COLUMNS - 2; // At 6 letters, only the 2nd row (index 1) has less than the max columns
|
|
|
|
// The 3rd and 4th row have 7 letters, the 1st row has 6 letters and 'Others'
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ReduceToValidKeyboardColumn(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
while (IsSelectedKeyboardIndexInvalid())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->keyboardColumn)
|
|
|
|
sEasyChatScreen->keyboardColumn--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ReduceToValidWordSelectColumn(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
while (IsSelectedWordIndexInvalid())
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->wordSelectColumn)
|
|
|
|
sEasyChatScreen->wordSelectColumn--;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsSelectedKeyboardIndexInvalid(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!sEasyChatScreen->inAlphabetMode)
|
|
|
|
return GetSelectedGroupIndex() >= GetNumUnlockedEasyChatGroups() ? TRUE : FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->keyboardColumn > GetLastAlphabetColumn(sEasyChatScreen->keyboardRow) ? TRUE : FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsSelectedWordIndexInvalid(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return GetSelectedWordIndex() >= GetNumWordsInSelectedGroup() ? TRUE : FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static int FooterHasFourOptions(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreenTemplates[sEasyChatScreen->templateId].fourFooterOptions;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetEasyChatScreenType(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->type;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetEasyChatScreenFrameId(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreenTemplates[sEasyChatScreen->templateId].frameId;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
const u8 *GetTitleText(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->titleText;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 *GetCurrentPhrase(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->currentPhrase;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetNumRows(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->numRows;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetNumColumns(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->numColumns;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetMainCursorColumn(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->mainCursorColumn;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetMainCursorRow(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->mainCursorRow;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-23 19:59:20 +01:00
|
|
|
static void GetEasyChatInstructionsText(const u8 **str1, const u8 **str2)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
*str1 = sEasyChatScreenTemplates[sEasyChatScreen->templateId].instructionsText1;
|
|
|
|
*str2 = sEasyChatScreenTemplates[sEasyChatScreen->templateId].instructionsText2;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-23 19:59:20 +01:00
|
|
|
static void GetEasyChatConfirmText(const u8 **str1, const u8 **str2)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
*str1 = sEasyChatScreenTemplates[sEasyChatScreen->templateId].confirmText1;
|
|
|
|
*str2 = sEasyChatScreenTemplates[sEasyChatScreen->templateId].confirmText2;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void GetEasyChatConfirmExitText(const u8 **str1, const u8 **str2)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (sEasyChatScreen->type)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_MAIL:
|
2019-02-22 00:40:20 +01:00
|
|
|
*str1 = gText_StopGivingPkmnMail;
|
|
|
|
*str2 = NULL;
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUIZ_ANSWER:
|
|
|
|
case EASY_CHAT_TYPE_QUIZ_QUESTION:
|
2019-02-22 00:40:20 +01:00
|
|
|
*str1 = gText_LikeToQuitQuiz;
|
|
|
|
*str2 = gText_ChallengeQuestionMark;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*str1 = gText_QuitEditing;
|
|
|
|
*str2 = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-02-23 19:59:20 +01:00
|
|
|
static void GetEasyChatConfirmDeletionText(const u8 **str1, const u8 **str2)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
*str1 = gText_AllTextBeingEditedWill;
|
|
|
|
*str2 = gText_BeDeletedThatOkay;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void GetKeyboardCursorColAndRow(u8 *column, u8 *row)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
*column = sEasyChatScreen->keyboardColumn;
|
|
|
|
*row = sEasyChatScreen->keyboardRow;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 GetInAlphabetMode(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->inAlphabetMode;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetKeyboardScrollOffset(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->keyboardScrollOffset;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void GetWordSelectColAndRow(u8 *column, u8 *row)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
*column = sEasyChatScreen->wordSelectColumn;
|
|
|
|
*row = sEasyChatScreen->wordSelectRow;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetWordSelectScrollOffset(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->wordSelectScrollOffset;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetWordSelectLastRow(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatScreen->wordSelectLastRow;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 UnusedDummy(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 CanScrollUp(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sEasyChatScreen->inputState)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUTSTATE_KEYBOARD:
|
|
|
|
if (!sEasyChatScreen->inAlphabetMode && sEasyChatScreen->keyboardScrollOffset)
|
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUTSTATE_WORD_SELECT:
|
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset)
|
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 CanScrollDown(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sEasyChatScreen->inputState)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUTSTATE_KEYBOARD:
|
|
|
|
if (!sEasyChatScreen->inAlphabetMode && sEasyChatScreen->keyboardScrollOffset + NUM_GROUP_NAME_ROWS <= sEasyChatScreen->keyboardLastRow - 1)
|
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case INPUTSTATE_WORD_SELECT:
|
|
|
|
if (sEasyChatScreen->wordSelectScrollOffset + NUM_WORD_SELECT_ROWS <= sEasyChatScreen->wordSelectLastRow)
|
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static int FooterHasFourOptions_(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return FooterHasFourOptions();
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-10-07 16:34:12 +02:00
|
|
|
static bool8 IsPhraseDifferentThanPlayerInput(const u16 *phrase, u8 phraseLength)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-10-07 16:34:12 +02:00
|
|
|
for (i = 0; i < phraseLength; i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (phrase[i] != sEasyChatScreen->currentPhrase[i])
|
2019-10-07 16:34:12 +02:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-10-07 16:34:12 +02:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetDisplayedPersonType(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
return sEasyChatScreen->displayedPersonType;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static u8 GetEachChatScreenTemplateId(u8 type)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sEasyChatScreenTemplates); i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreenTemplates[i].type == type)
|
2019-02-22 00:40:20 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 IsCurrentPhraseEmpty(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->currentPhrase[i] != EC_EMPTY_WORD)
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 IsCurrentPhraseFull(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sEasyChatScreen->maxWords; i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sEasyChatScreen->currentPhrase[i] == EC_EMPTY_WORD)
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int IsQuizQuestionEmpty(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct SaveBlock1 *saveBlock1;
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_QUESTION)
|
2021-02-22 18:12:35 +01:00
|
|
|
return IsCurrentPhraseEmpty();
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2019-02-22 00:40:20 +01:00
|
|
|
saveBlock1 = gSaveBlock1Ptr;
|
2019-08-06 02:37:09 +02:00
|
|
|
for (i = 0; i < QUIZ_QUESTION_LEN; i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (saveBlock1->lilycoveLady.quiz.question[i] != EC_EMPTY_WORD)
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int IsQuizAnswerEmpty(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
struct LilycoveLadyQuiz *quiz;
|
2019-02-27 19:45:31 +01:00
|
|
|
if (sEasyChatScreen->type == EASY_CHAT_TYPE_QUIZ_SET_ANSWER)
|
2021-02-22 18:12:35 +01:00
|
|
|
return IsCurrentPhraseEmpty();
|
2019-02-22 00:40:20 +01:00
|
|
|
|
|
|
|
quiz = &gSaveBlock1Ptr->lilycoveLady.quiz;
|
2021-02-22 18:12:35 +01:00
|
|
|
return quiz->correctAnswer == EC_EMPTY_WORD ? TRUE : FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void GetQuizTitle(u8 *dst)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
u8 name[32];
|
|
|
|
struct SaveBlock1 *saveBlock1 = gSaveBlock1Ptr;
|
|
|
|
DynamicPlaceholderTextUtil_Reset();
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Buffer author's name
|
2019-02-22 00:40:20 +01:00
|
|
|
if (StringLength(saveBlock1->lilycoveLady.quiz.playerName) != 0)
|
|
|
|
{
|
|
|
|
TVShowConvertInternationalString(name, saveBlock1->lilycoveLady.quiz.playerName, saveBlock1->lilycoveLady.quiz.language);
|
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gText_Lady);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// "<author>'s Quiz"
|
|
|
|
DynamicPlaceholderTextUtil_ExpandPlaceholders(dst, gText_F700sQuiz);
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void BufferCurrentPhraseToStringVar2(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 *phrase;
|
2019-02-22 00:40:20 +01:00
|
|
|
u8 *str;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
phrase = sEasyChatScreen->currentPhrase;
|
2019-02-22 00:40:20 +01:00
|
|
|
str = gStringVar2;
|
|
|
|
i = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
while (i < sEasyChatScreen->maxWords)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
str = CopyEasyChatWordPadded(str, *phrase, 0);
|
2019-02-22 00:40:20 +01:00
|
|
|
*str = 0;
|
|
|
|
str++;
|
2021-02-22 18:12:35 +01:00
|
|
|
phrase++;
|
2019-02-22 00:40:20 +01:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
str--;
|
2021-02-22 18:12:35 +01:00
|
|
|
str[0] = EOS;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetSpecialEasyChatResult(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (sEasyChatScreen->type)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_PROFILE:
|
2019-02-22 00:40:20 +01:00
|
|
|
FlagSet(FLAG_SYS_CHAT_USED);
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_QUESTIONNAIRE:
|
2019-10-07 16:34:12 +02:00
|
|
|
if (DidPlayerInputMysteryGiftPhrase())
|
2019-02-22 00:40:20 +01:00
|
|
|
gSpecialVar_0x8004 = 2;
|
|
|
|
else
|
|
|
|
gSpecialVar_0x8004 = 0;
|
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_TRENDY_PHRASE:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferCurrentPhraseToStringVar2();
|
2021-03-31 21:53:01 +02:00
|
|
|
gSpecialVar_0x8004 = TrySetTrendyPhrase(sEasyChatScreen->currentPhrase);
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_TYPE_GOOD_SAYING:
|
2019-10-07 16:34:12 +02:00
|
|
|
gSpecialVar_0x8004 = DidPlayerInputABerryMasterWifePhrase();
|
2019-02-22 00:40:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-07 16:34:12 +02:00
|
|
|
static int DidPlayerInputMysteryGiftPhrase(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-10-07 16:34:12 +02:00
|
|
|
return !IsPhraseDifferentThanPlayerInput(sMysteryGiftPhrase, ARRAY_COUNT(sMysteryGiftPhrase));
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2019-10-07 16:34:12 +02:00
|
|
|
static u16 DidPlayerInputABerryMasterWifePhrase(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
2019-10-07 16:34:12 +02:00
|
|
|
for (i = 0; i < (int)ARRAY_COUNT(sBerryMasterWifePhrases); i++)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2019-10-07 16:34:12 +02:00
|
|
|
if (!IsPhraseDifferentThanPlayerInput(sBerryMasterWifePhrases[i], ARRAY_COUNT(*sBerryMasterWifePhrases)))
|
2019-02-22 00:40:20 +01:00
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ClearUnusedField(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sEasyChatScreen->unused = 0;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool32 DummyWordCheck(int easyChatWord)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 InitEasyChatScreenControl(void)
|
2019-02-22 00:40:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!InitEasyChatScreenControl_())
|
|
|
|
return FALSE;
|
2019-02-22 00:40:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return TRUE;
|
2019-02-22 00:40:20 +01:00
|
|
|
}
|
2019-02-22 18:40:32 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 LoadEasyChatScreen(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2019-02-26 18:24:12 +01:00
|
|
|
InitBgsFromTemplates(0, sEasyChatBgTemplates, ARRAY_COUNT(sEasyChatBgTemplates));
|
2021-02-22 18:12:35 +01:00
|
|
|
SetBgTilemapBuffer(3, sScreenControl->bg3TilemapBuffer);
|
|
|
|
SetBgTilemapBuffer(1, sScreenControl->bg1TilemapBuffer);
|
2019-02-26 18:24:12 +01:00
|
|
|
InitWindows(sEasyChatWindowTemplates);
|
2019-02-22 18:40:32 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2021-02-22 18:12:35 +01:00
|
|
|
LoadEasyChatPalettes();
|
|
|
|
InitEasyChatBgs();
|
2020-05-25 11:11:52 +02:00
|
|
|
CpuFastFill(0, (void *)OAM, OAM_SIZE);
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
DecompressAndLoadBgGfxUsingHeap(3, gEasyChatWindow_Gfx, 0, 0, 0);
|
|
|
|
CopyToBgTilemapBuffer(3, gEasyChatWindow_Tilemap, 0, 0);
|
2021-02-22 18:12:35 +01:00
|
|
|
AdjustBgTilemapForFooter();
|
|
|
|
BufferFrameTilemap(sScreenControl->bg1TilemapBuffer);
|
|
|
|
AddPhraseWindow();
|
|
|
|
AddMainScreenButtonWindow();
|
2019-02-22 18:40:32 +01:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
DecompressAndLoadBgGfxUsingHeap(1, sTextInputFrame_Gfx, 0, 0, 0);
|
2019-02-22 18:40:32 +01:00
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintTitle();
|
|
|
|
PrintInitialInstructions();
|
|
|
|
PrintCurrentPhrase();
|
|
|
|
DrawLowerWindow();
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-02-22 18:12:35 +01:00
|
|
|
LoadEasyChatGfx();
|
2019-02-27 19:45:31 +01:00
|
|
|
if (GetEasyChatScreenType() != EASY_CHAT_TYPE_QUIZ_QUESTION)
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateMainCursorSprite();
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
SetWindowDimensions(0, 0, 0, 0);
|
2020-05-25 11:19:45 +02:00
|
|
|
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0
|
|
|
|
| WINOUT_WIN01_BG1
|
|
|
|
| WINOUT_WIN01_BG3
|
|
|
|
| WINOUT_WIN01_OBJ
|
|
|
|
| WINOUT_WIN01_CLR);
|
2019-02-22 18:40:32 +01:00
|
|
|
ShowBg(3);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
ShowBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateScrollIndicatorSprites();
|
|
|
|
CreateStartSelectButtonSprites();
|
|
|
|
TryAddInterviewObjectEvents();
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void FreeEasyChatScreenControl(void)
|
|
|
|
{
|
2022-06-03 16:42:53 +02:00
|
|
|
TRY_FREE_AND_SET_NULL(sScreenControl);
|
2021-02-22 18:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void StartEasyChatFunction(u16 funcId)
|
|
|
|
{
|
|
|
|
sScreenControl->currentFuncId = funcId;
|
|
|
|
sScreenControl->funcState = 0;
|
|
|
|
RunEasyChatFunction();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns FALSE when called function has finished
|
|
|
|
static bool8 RunEasyChatFunction(void)
|
|
|
|
{
|
|
|
|
switch (sScreenControl->currentFuncId)
|
|
|
|
{
|
|
|
|
case ECFUNC_NONE: return FALSE;
|
|
|
|
case ECFUNC_REPRINT_PHRASE: return ReprintPhrase();
|
|
|
|
case ECFUNC_UPDATE_MAIN_CURSOR: return UpdateMainCursor();
|
|
|
|
case ECFUNC_UPDATE_MAIN_CURSOR_ON_BUTTONS: return UpdateMainCursorOnButtons();
|
|
|
|
case ECFUNC_PROMPT_DELETE_ALL: return ShowConfirmDeleteAllPrompt();
|
|
|
|
case ECFUNC_PROMPT_EXIT: return ShowConfirmExitPrompt();
|
|
|
|
case ECFUNC_PROMPT_CONFIRM: return ShowConfirmPrompt();
|
|
|
|
case ECFUNC_CLOSE_PROMPT: return ClosePrompt();
|
|
|
|
case ECFUNC_CLOSE_PROMPT_AFTER_DELETE: return ClosePromptAfterDeleteAll();
|
|
|
|
case ECFUNC_OPEN_KEYBOARD: return OpenKeyboard();
|
|
|
|
case ECFUNC_CLOSE_KEYBOARD: return CloseKeyboard();
|
|
|
|
case ECFUNC_OPEN_WORD_SELECT: return OpenWordSelect();
|
|
|
|
case ECFUNC_CLOSE_WORD_SELECT: return CloseWordSelect();
|
|
|
|
case ECFUNC_PROMPT_CONFIRM_LYRICS: return ShowConfirmLyricsPrompt();
|
|
|
|
case ECFUNC_RETURN_TO_KEYBOARD: return ReturnToKeyboard();
|
|
|
|
case ECFUNC_UPDATE_KEYBOARD_CURSOR: return UpdateKeyboardCursor();
|
|
|
|
case ECFUNC_GROUP_NAMES_SCROLL_DOWN: return GroupNamesScrollDown();
|
|
|
|
case ECFUNC_GROUP_NAMES_SCROLL_UP: return GroupNamesScrollUp();
|
|
|
|
case ECFUNC_UPDATE_WORD_SELECT_CURSOR: return UpdateWordSelectCursor();
|
|
|
|
case ECFUNC_WORD_SELECT_SCROLL_UP: return WordSelectScrollUp();
|
|
|
|
case ECFUNC_WORD_SELECT_SCROLL_DOWN: return WordSelectScrollDown();
|
|
|
|
case ECFUNC_WORD_SELECT_PAGE_UP: return WordSelectPageScrollUp();
|
|
|
|
case ECFUNC_WORD_SELECT_PAGE_DOWN: return WordSelectPageScrollDown();
|
|
|
|
case ECFUNC_SWITCH_KEYBOARD_MODE: return SwitchKeyboardMode();
|
|
|
|
case ECFUNC_EXIT: return FALSE;
|
|
|
|
case ECFUNC_QUIZ_QUESTION: return FALSE; // The 4 quiz functions
|
|
|
|
case ECFUNC_QUIZ_ANSWER: return FALSE; // 'finish' automatically
|
|
|
|
case ECFUNC_SET_QUIZ_QUESTION: return FALSE; // because they switch to a
|
|
|
|
case ECFUNC_SET_QUIZ_ANSWER: return FALSE; // callback in sQuizLadyEasyChatScreens
|
|
|
|
case ECFUNC_MSG_CREATE_QUIZ: return ShowCreateQuizMsg();
|
|
|
|
case ECFUNC_MSG_SELECT_ANSWER: return ShowSelectAnswerMsg();
|
|
|
|
case ECFUNC_MSG_SONG_TOO_SHORT: return ShowSongTooShortMsg();
|
|
|
|
case ECFUNC_MSG_CANT_DELETE_LYRICS: return ShowCantDeleteLyricsMsg();
|
|
|
|
case ECFUNC_MSG_COMBINE_TWO_WORDS: return ShowCombineTwoWordsMsg();
|
|
|
|
case ECFUNC_MSG_CANT_EXIT: return ShowCantExitMsg();
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only used to update the current phrase after a word deletion
|
|
|
|
static bool8 ReprintPhrase(void)
|
|
|
|
{
|
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintCurrentPhrase();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 UpdateMainCursor(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 *currentPhrase;
|
2019-02-22 18:40:32 +01:00
|
|
|
u16 *ecWord;
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId;
|
2019-02-22 18:40:32 +01:00
|
|
|
u8 cursorColumn, cursorRow, numColumns;
|
2021-02-22 18:12:35 +01:00
|
|
|
s16 x;
|
2019-02-22 18:40:32 +01:00
|
|
|
int stringWidth;
|
|
|
|
int trueStringWidth;
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 y;
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 str[64];
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
currentPhrase = GetCurrentPhrase();
|
2019-02-27 19:45:31 +01:00
|
|
|
frameId = GetEasyChatScreenFrameId();
|
|
|
|
cursorColumn = GetMainCursorColumn();
|
|
|
|
cursorRow = GetMainCursorRow();
|
|
|
|
numColumns = GetNumColumns();
|
2021-02-22 18:12:35 +01:00
|
|
|
ecWord = ¤tPhrase[cursorRow * numColumns];
|
|
|
|
x = 8 * sPhraseFrameDimensions[frameId].left + 13;
|
2019-02-22 18:40:32 +01:00
|
|
|
for (i = 0; i < cursorColumn; i++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (*ecWord == EC_EMPTY_WORD)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
stringWidth = 72;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
CopyEasyChatWord(str, *ecWord);
|
2021-10-30 22:47:37 +02:00
|
|
|
stringWidth = GetStringWidth(FONT_NORMAL, str, 0);
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
trueStringWidth = stringWidth + 17;
|
2021-02-22 18:12:35 +01:00
|
|
|
x += trueStringWidth;
|
2019-02-22 18:40:32 +01:00
|
|
|
ecWord++;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
y = 8 * (sPhraseFrameDimensions[frameId].top + cursorRow * 2);
|
|
|
|
SetMainCursorPos(x, y + 8);
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 UpdateMainCursorOnButtons(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 xOffset = GetFooterOptionXOffset(GetMainCursorColumn());
|
2021-02-22 18:12:35 +01:00
|
|
|
SetMainCursorPos(xOffset, 96);
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowConfirmExitPrompt(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CONFIRM_EXIT);
|
|
|
|
CreateEasyChatYesNoMenu(1);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowConfirmPrompt(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CONFIRM);
|
|
|
|
CreateEasyChatYesNoMenu(0);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowConfirmDeleteAllPrompt(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CONFIRM_DELETE);
|
|
|
|
CreateEasyChatYesNoMenu(1);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ClosePrompt(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StartMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_INSTRUCTIONS);
|
|
|
|
PrintCurrentPhrase();
|
2019-02-22 18:40:32 +01:00
|
|
|
ShowBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ClosePromptAfterDeleteAll(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StartMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_INSTRUCTIONS);
|
|
|
|
PrintCurrentPhrase();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
// Fall through
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 OpenKeyboard(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
2019-02-22 18:40:32 +01:00
|
|
|
HideBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
SetWindowDimensions(0, 0, 0, 0);
|
|
|
|
PrintKeyboardText();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_OPEN_KEYBOARD);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy() && !UpdateLowerWindowAnim())
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateSideWindowSprites();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!ShowSideWindow())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateRectangleCursorSprites();
|
|
|
|
SetScrollIndicatorXPos(FALSE);
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 CloseKeyboard(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyRectangleCursorSprites();
|
|
|
|
HideModeWindow();
|
|
|
|
HideScrollIndicators();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (DestroySideWindowSprites() == TRUE)
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_CLOSE_KEYBOARD);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
// Fall through
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim())
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
StartMainCursorAnim();
|
2019-02-22 18:40:32 +01:00
|
|
|
ShowBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 SwitchKeyboardMode(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyRectangleCursorSprites();
|
|
|
|
HideScrollIndicators();
|
|
|
|
SetModeWindowToTransition();
|
|
|
|
InitLowerWindowAnim(WINANIM_KEYBOARD_SWITCH_OUT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim() && !IsModeWindowAnimActive())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintKeyboardText();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_KEYBOARD_SWITCH_IN);
|
|
|
|
UpdateModeWindowAnim();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim() && !IsModeWindowAnimActive())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
CreateRectangleCursorSprites();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 UpdateKeyboardCursor(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateRectangleCursorPos();
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 GroupNamesScrollDown(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowScroll(1, 4);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
// Fall through
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateRectangleCursorPos();
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 GroupNamesScrollUp(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowScroll(-1, 4);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
// Fall through
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 OpenWordSelect(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyRectangleCursorSprites();
|
|
|
|
HideModeWindow();
|
|
|
|
HideScrollIndicators();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!DestroySideWindowSprites())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
ClearWordSelectWindow();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_OPEN_WORD_SELECT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowText(TEXT_WORD_SELECT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateWordSelectCursorSprite();
|
|
|
|
SetScrollIndicatorXPos(TRUE);
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
UpdateStartSelectButtonsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 CloseWordSelect(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintCurrentPhrase();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyWordSelectCursorSprite();
|
|
|
|
HideScrollIndicators();
|
|
|
|
HideStartSelectButtons();
|
|
|
|
ClearWordSelectWindow();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_CLOSE_WORD_SELECT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
ShowBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
StartMainCursorAnim();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowConfirmLyricsPrompt(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintCurrentPhrase();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyWordSelectCursorSprite();
|
|
|
|
HideScrollIndicators();
|
|
|
|
HideStartSelectButtons();
|
|
|
|
ClearWordSelectWindow();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_CLOSE_WORD_SELECT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintEasyChatStdMessage(MSG_CONFIRM);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
ShowBg(0);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
StartMainCursorAnim();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ReturnToKeyboard(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroyWordSelectCursorSprite();
|
|
|
|
HideScrollIndicators();
|
|
|
|
HideStartSelectButtons();
|
|
|
|
ClearWordSelectWindow();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowAnim(WINANIM_RETURN_TO_KEYBOARD);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowAnim())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintKeyboardText();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateSideWindowSprites();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!ShowSideWindow())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CreateRectangleCursorSprites();
|
|
|
|
SetScrollIndicatorXPos(FALSE);
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 UpdateWordSelectCursor(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateWordSelectCursorPos();
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 WordSelectScrollDown(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintWordSelectNextRowDown();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowScroll(1, 4);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateWordSelectCursorPos();
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
UpdateStartSelectButtonsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 WordSelectScrollUp(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintWordSelectNextRowUp();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowScroll(-1, 4);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
UpdateStartSelectButtonsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 WordSelectPageScrollDown(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintWordSelectRowsPageDown();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
s16 scrollChange = GetWordSelectScrollOffset() - GetLowerWindowScrollOffset();
|
|
|
|
InitLowerWindowScroll(scrollChange, 8);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateWordSelectCursorPos();
|
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
UpdateStartSelectButtonsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 WordSelectPageScrollUp(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintWordSelectRowsPageUp();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
s16 scrollChange = GetWordSelectScrollOffset() - GetLowerWindowScrollOffset();
|
|
|
|
InitLowerWindowScroll(scrollChange, 8);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!UpdateLowerWindowScroll())
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
UpdateScrollIndicatorsVisibility();
|
|
|
|
UpdateStartSelectButtonsVisibility();
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowCreateQuizMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CREATE_QUIZ);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowSelectAnswerMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_SELECT_ANSWER);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowSongTooShortMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_SONG_TOO_SHORT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowCantDeleteLyricsMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CANT_DELETE_LYRICS);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowCombineTwoWordsMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_COMBINE_TWO_WORDS);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowCantExitMsg(void)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->funcState)
|
2019-02-22 18:40:32 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
StopMainCursorAnim();
|
|
|
|
PrintEasyChatStdMessage(MSG_CANT_QUIT);
|
|
|
|
sScreenControl->funcState++;
|
2019-02-22 18:40:32 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 InitEasyChatScreenControl_(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl = Alloc(sizeof(*sScreenControl));
|
|
|
|
if (!sScreenControl)
|
2019-02-23 19:59:20 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->funcState = 0;
|
|
|
|
sScreenControl->mainCursorSprite = NULL;
|
|
|
|
sScreenControl->rectangleCursorSpriteRight = NULL;
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft = NULL;
|
|
|
|
sScreenControl->wordSelectCursorSprite = NULL;
|
|
|
|
sScreenControl->buttonWindowSprite = NULL;
|
|
|
|
sScreenControl->modeWindowSprite = NULL;
|
|
|
|
sScreenControl->scrollIndicatorUpSprite = NULL;
|
|
|
|
sScreenControl->scrollIndicatorDownSprite = NULL;
|
|
|
|
sScreenControl->startButtonSprite = NULL;
|
|
|
|
sScreenControl->selectButtonSprite = NULL;
|
|
|
|
sScreenControl->fourFooterOptions = FooterHasFourOptions_();
|
2019-02-23 19:59:20 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void InitEasyChatBgs(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgX(3, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(3, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
2019-02-23 19:59:20 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void LoadEasyChatPalettes(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
ResetPaletteFade();
|
2022-08-19 17:32:00 +02:00
|
|
|
LoadPalette(gEasyChatMode_Pal, BG_PLTT_ID(0), PLTT_SIZE_4BPP);
|
|
|
|
LoadPalette(sTextInputFrameOrange_Pal, BG_PLTT_ID(1), PLTT_SIZE_4BPP);
|
|
|
|
LoadPalette(sTextInputFrameGreen_Pal, BG_PLTT_ID(4), PLTT_SIZE_4BPP);
|
|
|
|
LoadPalette(sTitleText_Pal, BG_PLTT_ID(10), PLTT_SIZEOF(4));
|
|
|
|
LoadPalette(sText_Pal, BG_PLTT_ID(11), PLTT_SIZEOF(6));
|
|
|
|
LoadPalette(sText_Pal, BG_PLTT_ID(15), PLTT_SIZEOF(6));
|
|
|
|
LoadPalette(sText_Pal, BG_PLTT_ID(3), PLTT_SIZEOF(6));
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintTitle(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
int xOffset;
|
2019-02-27 19:45:31 +01:00
|
|
|
const u8 *titleText = GetTitleText();
|
2019-02-23 19:59:20 +01:00
|
|
|
if (!titleText)
|
|
|
|
return;
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
xOffset = GetStringCenterAlignXOffset(FONT_NORMAL, titleText, 144);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(0));
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatTextWithColors(0, FONT_NORMAL, titleText, xOffset, 1, TEXT_SKIP_DRAW, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY);
|
2019-02-23 19:59:20 +01:00
|
|
|
PutWindowTilemap(0);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(0, COPYWIN_FULL);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintEasyChatText(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16))
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
AddTextPrinterParameterized(windowId, fontId, str, x, y, speed, callback);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintEasyChatTextWithColors(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, u8 bg, u8 fg, u8 shadow)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
u8 color[3];
|
2019-12-10 19:48:20 +01:00
|
|
|
color[0] = bg;
|
|
|
|
color[1] = fg;
|
|
|
|
color[2] = shadow;
|
2019-02-23 19:59:20 +01:00
|
|
|
AddTextPrinterParameterized3(windowId, fontId, left, top, color, speed, str);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintInitialInstructions(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17);
|
2022-08-19 17:32:00 +02:00
|
|
|
LoadUserWindowBorderGfx(1, 1, BG_PLTT_ID(14));
|
|
|
|
DrawTextBorderOuter(1, 1, 14);
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintEasyChatStdMessage(MSG_INSTRUCTIONS);
|
2019-02-23 19:59:20 +01:00
|
|
|
PutWindowTilemap(1);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintEasyChatStdMessage(u8 msgId)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
const u8 *text2 = NULL;
|
|
|
|
const u8 *text1 = NULL;
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (msgId)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_INSTRUCTIONS:
|
2019-02-23 19:59:20 +01:00
|
|
|
GetEasyChatInstructionsText(&text1, &text2);
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CONFIRM_EXIT:
|
|
|
|
GetEasyChatConfirmExitText(&text1, &text2);
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CONFIRM:
|
2019-02-23 19:59:20 +01:00
|
|
|
GetEasyChatConfirmText(&text1, &text2);
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CONFIRM_DELETE:
|
2019-02-23 19:59:20 +01:00
|
|
|
GetEasyChatConfirmDeletionText(&text1, &text2);
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CREATE_QUIZ:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_CreateAQuiz;
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_SELECT_ANSWER:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_SelectTheAnswer;
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_SONG_TOO_SHORT:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_OnlyOnePhrase;
|
|
|
|
text2 = gText_OriginalSongWillBeUsed;
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CANT_DELETE_LYRICS:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_LyricsCantBeDeleted;
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_COMBINE_TWO_WORDS:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_CombineTwoWordsOrPhrases3;
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case MSG_CANT_QUIT:
|
2019-02-23 19:59:20 +01:00
|
|
|
text1 = gText_YouCannotQuitHere;
|
|
|
|
text2 = gText_SectionMustBeCompleted;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(1));
|
2019-02-23 19:59:20 +01:00
|
|
|
if (text1)
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(1, FONT_NORMAL, text1, 0, 1, TEXT_SKIP_DRAW, 0);
|
2019-02-23 19:59:20 +01:00
|
|
|
|
|
|
|
if (text2)
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(1, FONT_NORMAL, text2, 0, 17, TEXT_SKIP_DRAW, 0);
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(1, COPYWIN_FULL);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void CreateEasyChatYesNoMenu(u8 initialCursorPos)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-02-26 18:24:12 +01:00
|
|
|
CreateYesNoMenu(&sEasyChatYesNoWindowTemplate, 1, 14, initialCursorPos);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void AddPhraseWindow(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId;
|
2019-02-23 19:59:20 +01:00
|
|
|
struct WindowTemplate template;
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
frameId = GetEasyChatScreenFrameId();
|
2019-02-23 19:59:20 +01:00
|
|
|
template.bg = 3;
|
2019-02-27 19:45:31 +01:00
|
|
|
template.tilemapLeft = sPhraseFrameDimensions[frameId].left;
|
|
|
|
template.tilemapTop = sPhraseFrameDimensions[frameId].top;
|
|
|
|
template.width = sPhraseFrameDimensions[frameId].width;
|
|
|
|
template.height = sPhraseFrameDimensions[frameId].height;
|
2022-08-19 17:32:00 +02:00
|
|
|
template.paletteNum = 11;
|
2019-02-23 19:59:20 +01:00
|
|
|
template.baseBlock = 0x6C;
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->windowId = AddWindow(&template);
|
|
|
|
PutWindowTilemap(sScreenControl->windowId);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintCurrentPhrase(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 strClear[4];
|
|
|
|
u16 *currentPhrase;
|
2019-02-23 19:59:20 +01:00
|
|
|
u8 numColumns, numRows;
|
|
|
|
u8 *str;
|
2019-02-27 19:45:31 +01:00
|
|
|
int frameId;
|
2021-02-22 18:12:35 +01:00
|
|
|
bool32 isQuizQuestion;
|
2019-02-23 19:59:20 +01:00
|
|
|
int i, j, k;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
currentPhrase = GetCurrentPhrase();
|
2019-02-27 19:45:31 +01:00
|
|
|
numColumns = GetNumColumns();
|
|
|
|
numRows = GetNumRows();
|
|
|
|
frameId = GetEasyChatScreenFrameId();
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
isQuizQuestion = FALSE;
|
|
|
|
if (frameId == FRAMEID_QUIZ_QUESTION)
|
|
|
|
isQuizQuestion = TRUE;
|
|
|
|
|
|
|
|
FillWindowPixelBuffer(sScreenControl->windowId, PIXEL_FILL(1));
|
2019-02-23 19:59:20 +01:00
|
|
|
for (i = 0; i < numRows; i++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
memcpy(strClear, sText_Clear17, sizeof(sText_Clear17));
|
|
|
|
if (isQuizQuestion)
|
|
|
|
strClear[2] = 6;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
str = sScreenControl->phrasePrintBuffer;
|
|
|
|
sScreenControl->phrasePrintBuffer[0] = EOS;
|
|
|
|
str = StringAppend(str, strClear);
|
2019-02-23 19:59:20 +01:00
|
|
|
for (j = 0; j < numColumns; j++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (*currentPhrase != EC_EMPTY_WORD)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
str = CopyEasyChatWord(str, *currentPhrase);
|
|
|
|
currentPhrase++;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
currentPhrase++;
|
|
|
|
if (!isQuizQuestion)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
str = WriteColorChangeControlCode(str, 0, 4);
|
|
|
|
for (k = 0; k < 12; k++)
|
|
|
|
{
|
|
|
|
*str = CHAR_HYPHEN;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = WriteColorChangeControlCode(str, 0, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (isQuizQuestion)
|
|
|
|
strClear[2] = 3;
|
|
|
|
|
|
|
|
str = StringAppend(str, strClear);
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (frameId == FRAMEID_MAIL || frameId == FRAMEID_QUIZ_QUESTION || frameId == FRAMEID_QUIZ_SET_QUESTION)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Is 2x5 frame, end on 9th word
|
2019-02-23 19:59:20 +01:00
|
|
|
if (j == 0 && i == 4)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*str = EOS;
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(sScreenControl->windowId, FONT_NORMAL, sScreenControl->phrasePrintBuffer, 0, i * 16 + 1, TEXT_SKIP_DRAW, 0);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(sScreenControl->windowId, COPYWIN_FULL);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void BufferFrameTilemap(u16 *tilemap)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId;
|
2019-02-23 19:59:20 +01:00
|
|
|
int right, bottom;
|
|
|
|
int x, y;
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
frameId = GetEasyChatScreenFrameId();
|
2019-02-23 19:59:20 +01:00
|
|
|
CpuFastFill(0, tilemap, BG_SCREEN_SIZE);
|
2021-02-22 18:12:35 +01:00
|
|
|
if (frameId == FRAMEID_MAIL || frameId == FRAMEID_QUIZ_SET_QUESTION)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// These frames fill the screen, no need to draw top/bottom edges
|
2019-02-27 19:45:31 +01:00
|
|
|
right = sPhraseFrameDimensions[frameId].left + sPhraseFrameDimensions[frameId].width;
|
|
|
|
bottom = sPhraseFrameDimensions[frameId].top + sPhraseFrameDimensions[frameId].height;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Draw middle section
|
2019-02-27 19:45:31 +01:00
|
|
|
for (y = sPhraseFrameDimensions[frameId].top; y < bottom; y++)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
x = sPhraseFrameDimensions[frameId].left - 1;
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_L_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
x++;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_TRANSPARENT;
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y* 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_R_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
y = sPhraseFrameDimensions[frameId].top - 1;
|
|
|
|
x = sPhraseFrameDimensions[frameId].left - 1;
|
|
|
|
right = sPhraseFrameDimensions[frameId].left + sPhraseFrameDimensions[frameId].width;
|
|
|
|
bottom = sPhraseFrameDimensions[frameId].top + sPhraseFrameDimensions[frameId].height;
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
// Draw top edge
|
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_TOP_L_CORNER;
|
2019-02-23 19:59:20 +01:00
|
|
|
x++;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_TOP_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_TOP_R_CORNER;
|
2019-02-23 19:59:20 +01:00
|
|
|
y++;
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
// Draw middle section
|
2019-02-23 19:59:20 +01:00
|
|
|
for (; y < bottom; y++)
|
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
x = sPhraseFrameDimensions[frameId].left - 1;
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_L_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
x++;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_TRANSPARENT;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y* 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_R_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Draw bottom edge
|
2019-02-27 19:45:31 +01:00
|
|
|
x = sPhraseFrameDimensions[frameId].left - 1;
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_BOTTOM_L_CORNER;
|
2019-02-23 19:59:20 +01:00
|
|
|
x++;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_BOTTOM_EDGE;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_ORANGE + FRAME_TILE_BOTTOM_R_CORNER;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void AdjustBgTilemapForFooter(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId;
|
2019-02-23 19:59:20 +01:00
|
|
|
u16 *tilemap;
|
|
|
|
|
|
|
|
tilemap = GetBgTilemapBuffer(3);
|
2019-02-27 19:45:31 +01:00
|
|
|
frameId = GetEasyChatScreenFrameId();
|
|
|
|
switch (sPhraseFrameDimensions[frameId].footerId)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case FOOTER_ANSWER:
|
2019-02-23 19:59:20 +01:00
|
|
|
tilemap += 0x2A0;
|
|
|
|
CopyToBgTilemapBufferRect(3, tilemap, 0, 11, 32, 2);
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case FOOTER_QUIZ:
|
2019-02-23 19:59:20 +01:00
|
|
|
tilemap += 0x300;
|
|
|
|
CopyToBgTilemapBufferRect(3, tilemap, 0, 11, 32, 2);
|
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case NUM_FOOTER_TYPES:
|
2019-02-23 19:59:20 +01:00
|
|
|
CopyToBgTilemapBufferRect(3, tilemap, 0, 10, 32, 4);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void DrawLowerWindow(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
PutWindowTilemap(2);
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void InitLowerWindowText(u32 whichText)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
ResetLowerWindowScroll();
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(2, PIXEL_FILL(1));
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (whichText)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case TEXT_GROUPS:
|
|
|
|
PrintKeyboardGroupNames();
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case TEXT_ALPHABET:
|
|
|
|
PrintKeyboardAlphabet();
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case TEXT_WORD_SELECT:
|
|
|
|
PrintInitialWordSelectText();
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(2, COPYWIN_GFX);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintKeyboardText(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!GetInAlphabetMode())
|
|
|
|
InitLowerWindowText(TEXT_GROUPS);
|
2019-02-23 19:59:20 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowText(TEXT_ALPHABET);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintKeyboardGroupNames(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
y = 97;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 2; x++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 groupId = GetUnlockedEasyChatGroupId(i++);
|
2019-02-26 18:17:41 +01:00
|
|
|
if (groupId == EC_NUM_GROUPS)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
InitLowerWindowScroll(GetKeyboardScrollOffset(), 0);
|
2019-02-23 19:59:20 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(2, FONT_NORMAL, GetEasyChatWordGroupName(groupId), x * 84 + 10, y, TEXT_SKIP_DRAW, NULL);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
y += 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintKeyboardAlphabet(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sEasyChatKeyboardAlphabet); i++)
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(2, FONT_NORMAL, sEasyChatKeyboardAlphabet[i], 10, 97 + i * 16, TEXT_SKIP_DRAW, NULL);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintInitialWordSelectText(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
PrintWordSelectText(0, NUM_WORD_SELECT_ROWS);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintWordSelectNextRowDown(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 wordScroll = GetWordSelectScrollOffset() + NUM_WORD_SELECT_ROWS - 1;
|
|
|
|
EraseWordSelectRows(wordScroll, 1);
|
|
|
|
PrintWordSelectText(wordScroll, 1);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintWordSelectNextRowUp(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 wordScroll = GetWordSelectScrollOffset();
|
|
|
|
EraseWordSelectRows(wordScroll, 1);
|
|
|
|
PrintWordSelectText(wordScroll, 1);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintWordSelectRowsPageDown(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 wordScroll = GetWordSelectScrollOffset();
|
|
|
|
u8 maxScroll = wordScroll + NUM_WORD_SELECT_ROWS;
|
|
|
|
u8 maxRows = GetWordSelectLastRow() + 1;
|
|
|
|
if (maxScroll > maxRows)
|
|
|
|
maxScroll = maxRows;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (wordScroll < maxScroll)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 numRows = maxScroll - wordScroll;
|
|
|
|
EraseWordSelectRows(wordScroll, numRows);
|
|
|
|
PrintWordSelectText(wordScroll, numRows);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void PrintWordSelectRowsPageUp(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 wordScroll = GetWordSelectScrollOffset();
|
|
|
|
u8 windowScroll = GetLowerWindowScrollOffset();
|
|
|
|
if (wordScroll < windowScroll)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 numRows = windowScroll - wordScroll;
|
|
|
|
EraseWordSelectRows(wordScroll, numRows);
|
|
|
|
PrintWordSelectText(wordScroll, numRows);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Print the easy chat words available for selection in
|
|
|
|
// the currently selected group and at the given offset and row
|
|
|
|
static void PrintWordSelectText(u8 scrollOffset, u8 numRows)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
u16 easyChatWord;
|
|
|
|
int y;
|
2021-02-22 18:12:35 +01:00
|
|
|
int wordIndex;
|
2019-02-23 19:59:20 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
wordIndex = scrollOffset * NUM_WORD_SELECT_COLUMNS;
|
|
|
|
y = (scrollOffset * 16 + 96) & 0xFF;
|
2019-02-23 19:59:20 +01:00
|
|
|
y++;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < numRows; i++)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
for (j = 0; j < 2; j++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
easyChatWord = GetWordFromSelectedGroup(wordIndex++);
|
|
|
|
if (easyChatWord != EC_EMPTY_WORD)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
CopyEasyChatWordPadded(sScreenControl->wordSelectPrintBuffer, easyChatWord, 0);
|
|
|
|
if (!DummyWordCheck(easyChatWord))
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatText(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, NULL);
|
2021-02-22 18:12:35 +01:00
|
|
|
else // Never reached
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintEasyChatTextWithColors(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GRAY);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
y += 16;
|
|
|
|
}
|
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(2, COPYWIN_GFX);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void EraseWordSelectRows(u8 scrollOffset, u8 numRows)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
|
|
|
int y;
|
|
|
|
int var0;
|
|
|
|
int var1;
|
|
|
|
int var2;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
y = (scrollOffset * 16 + 96) & 0xFF;
|
|
|
|
var2 = numRows * 16;
|
2019-02-23 19:59:20 +01:00
|
|
|
var0 = y + var2;
|
2021-02-22 18:12:35 +01:00
|
|
|
|
2019-02-23 19:59:20 +01:00
|
|
|
if (var0 > 255)
|
|
|
|
{
|
|
|
|
var1 = var0 - 256;
|
|
|
|
var2 = 256 - y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var1 = 0;
|
|
|
|
}
|
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelRect(2, PIXEL_FILL(1), 0, y, 224, var2);
|
2019-02-23 19:59:20 +01:00
|
|
|
if (var1)
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelRect(2, PIXEL_FILL(1), 0, 0, 224, var1);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ClearWordSelectWindow(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(2, PIXEL_FILL(1));
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(2, COPYWIN_GFX);
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void InitLowerWindowAnim(int winAnimType)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (winAnimType)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_OPEN_KEYBOARD:
|
|
|
|
sScreenControl->curWindowAnimState = 0;
|
|
|
|
sScreenControl->destWindowAnimState = 10;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_CLOSE_KEYBOARD:
|
|
|
|
sScreenControl->curWindowAnimState = 9;
|
|
|
|
sScreenControl->destWindowAnimState = 0;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_OPEN_WORD_SELECT:
|
|
|
|
sScreenControl->curWindowAnimState = 11;
|
|
|
|
sScreenControl->destWindowAnimState = 17;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_CLOSE_WORD_SELECT:
|
|
|
|
sScreenControl->curWindowAnimState = 17;
|
|
|
|
sScreenControl->destWindowAnimState = 0;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_RETURN_TO_KEYBOARD:
|
|
|
|
sScreenControl->curWindowAnimState = 17;
|
|
|
|
sScreenControl->destWindowAnimState = 10;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_KEYBOARD_SWITCH_OUT:
|
|
|
|
sScreenControl->curWindowAnimState = 18;
|
|
|
|
sScreenControl->destWindowAnimState = 22;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
2021-02-22 18:12:35 +01:00
|
|
|
case WINANIM_KEYBOARD_SWITCH_IN:
|
|
|
|
sScreenControl->curWindowAnimState = 22;
|
|
|
|
sScreenControl->destWindowAnimState = 18;
|
2019-02-23 19:59:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->windowAnimStateDir = sScreenControl->curWindowAnimState < sScreenControl->destWindowAnimState ? 1 : -1;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Returns FALSE if the anim is finished
|
|
|
|
static bool8 UpdateLowerWindowAnim(void)
|
2019-02-23 19:59:20 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 curState, destState;
|
|
|
|
if (sScreenControl->curWindowAnimState == sScreenControl->destWindowAnimState)
|
2019-02-23 19:59:20 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->curWindowAnimState += sScreenControl->windowAnimStateDir;
|
|
|
|
DrawLowerWindowFrame(sScreenControl->curWindowAnimState);
|
|
|
|
curState = sScreenControl->curWindowAnimState;
|
|
|
|
destState = sScreenControl->destWindowAnimState;
|
|
|
|
return (curState ^ destState) > 0;
|
2019-02-23 19:59:20 +01:00
|
|
|
}
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// States in this function are used incrementally with differing start/end cases
|
|
|
|
// to draw the lower window and create the appearance that it's opening/closing/animating.
|
|
|
|
// See InitLowerWindowAnim
|
|
|
|
static void DrawLowerWindowFrame(u8 type)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0, 0, 10, 30, 10);
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (type)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case 0: // Closed
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(11, 14, 3, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(9, 14, 7, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(7, 14, 11, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(5, 14, 15, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(3, 14, 19, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 14, 23, 2);
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
BufferLowerWindowFrame(1, 13, 23, 4);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
BufferLowerWindowFrame(1, 12, 23, 6);
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
BufferLowerWindowFrame(1, 11, 23, 8);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
BufferLowerWindowFrame(1, 10, 23, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 11:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 24, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 12:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 25, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 13:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 26, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 14:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 27, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 15:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 28, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 16:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 29, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 17:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(0, 10, 30, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 18:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 10, 23, 10);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 19:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 11, 23, 8);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 20:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 12, 23, 6);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 21:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 13, 23, 4);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 22:
|
2021-02-22 18:12:35 +01:00
|
|
|
BufferLowerWindowFrame(1, 14, 23, 2);
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void BufferLowerWindowFrame(int left, int top, int width, int height)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
u16 *tilemap;
|
|
|
|
int right;
|
|
|
|
int bottom;
|
|
|
|
int x, y;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap = sScreenControl->bg1TilemapBuffer;
|
2019-02-24 17:04:40 +01:00
|
|
|
right = left + width - 1;
|
|
|
|
bottom = top + height - 1;
|
|
|
|
x = left;
|
|
|
|
y = top;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Draw top edge
|
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_TOP_L_CORNER;
|
2019-02-24 17:04:40 +01:00
|
|
|
x++;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_TOP_EDGE;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_TOP_R_CORNER;
|
2019-02-24 17:04:40 +01:00
|
|
|
y++;
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
// Draw middle section
|
2019-02-24 17:04:40 +01:00
|
|
|
for (; y < bottom; y++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + left] = FRAME_OFFSET_GREEN + FRAME_TILE_L_EDGE;
|
2019-02-24 17:04:40 +01:00
|
|
|
x = left + 1;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_TRANSPARENT;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_R_EDGE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Draw bottom edge
|
|
|
|
tilemap[y * 32 + left] = FRAME_OFFSET_GREEN + FRAME_TILE_BOTTOM_L_CORNER;
|
2019-02-24 17:04:40 +01:00
|
|
|
x = left + 1;
|
|
|
|
for (; x < right; x++)
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_BOTTOM_EDGE;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
tilemap[y * 32 + x] = FRAME_OFFSET_GREEN + FRAME_TILE_BOTTOM_R_CORNER;
|
|
|
|
|
|
|
|
SetWindowDimensions((left + 1) * 8, (top + 1) * 8, (width - 2) * 8, (height - 2) * 8);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void ResetLowerWindowScroll(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgY(2, 0x800, BG_COORD_SET);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollOffset = 0;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void InitLowerWindowScroll(s16 scrollChange, u8 speed)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
int bgY;
|
2021-02-22 18:12:35 +01:00
|
|
|
s16 yChange;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
|
|
|
bgY = GetBgY(2);
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollOffset += scrollChange;
|
|
|
|
yChange = scrollChange * 16;
|
|
|
|
bgY += yChange * 256;
|
|
|
|
if (speed)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollDest = bgY;
|
|
|
|
sScreenControl->scrollSpeed = speed * 256;
|
|
|
|
if (yChange < 0)
|
|
|
|
sScreenControl->scrollSpeed = -sScreenControl->scrollSpeed;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgY(2, bgY, BG_COORD_SET);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 UpdateLowerWindowScroll(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
int bgY;
|
|
|
|
|
|
|
|
bgY = GetBgY(2);
|
2021-02-22 18:12:35 +01:00
|
|
|
if (bgY == sScreenControl->scrollDest)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgY(2, sScreenControl->scrollSpeed, BG_COORD_ADD);
|
2019-02-24 17:04:40 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static int GetLowerWindowScrollOffset(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sScreenControl->scrollOffset;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetWindowDimensions(u8 left, u8 top, u8 width, u8 height)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
u16 horizontalDimensions = WIN_RANGE(left, left + width);
|
|
|
|
u16 verticalDimensions = WIN_RANGE(top, top + height);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0H, horizontalDimensions);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0V, verticalDimensions);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void LoadEasyChatGfx(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
LoadSpriteSheets(sSpriteSheets);
|
|
|
|
LoadSpritePalettes(sSpritePalettes);
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sCompressedSpriteSheets); i++)
|
|
|
|
LoadCompressedSpriteSheet(&sCompressedSpriteSheets[i]);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
#define sDelayTimer data[0]
|
|
|
|
#define sAnimateCursor data[1]
|
|
|
|
|
|
|
|
static void CreateMainCursorSprite(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId = GetEasyChatScreenFrameId();
|
|
|
|
int x = sPhraseFrameDimensions[frameId].left * 8 + 13;
|
|
|
|
int y = sPhraseFrameDimensions[frameId].top * 8 + 8;
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_TriangleCursor, x, y, 2);
|
|
|
|
sScreenControl->mainCursorSprite = &gSprites[spriteId];
|
|
|
|
gSprites[spriteId].sAnimateCursor = TRUE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SpriteCB_Cursor(struct Sprite *sprite)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sprite->sAnimateCursor)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (++sprite->sDelayTimer > 2)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sprite->sDelayTimer = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (++sprite->x2 > 0)
|
|
|
|
sprite->x2 = -6;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetMainCursorPos(u8 x, u8 y)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->mainCursorSprite->x = x;
|
|
|
|
sScreenControl->mainCursorSprite->y = y;
|
|
|
|
sScreenControl->mainCursorSprite->x2 = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->mainCursorSprite->sDelayTimer = 0;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void StopMainCursorAnim(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->mainCursorSprite->sDelayTimer = 0;
|
|
|
|
sScreenControl->mainCursorSprite->sAnimateCursor = FALSE;
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->mainCursorSprite->x2 = 0;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void StartMainCursorAnim(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->mainCursorSprite->sAnimateCursor = TRUE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void CreateRectangleCursorSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_RectangleCursor, 0, 0, 3);
|
|
|
|
sScreenControl->rectangleCursorSpriteRight = &gSprites[spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->x2 = 32;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_RectangleCursor, 0, 0, 3);
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft = &gSprites[spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteLeft->x2 = -32;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->hFlip = TRUE;
|
|
|
|
UpdateRectangleCursorPos();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void DestroyRectangleCursorSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroySprite(sScreenControl->rectangleCursorSpriteRight);
|
|
|
|
sScreenControl->rectangleCursorSpriteRight = NULL;
|
|
|
|
DestroySprite(sScreenControl->rectangleCursorSpriteLeft);
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft = NULL;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void UpdateRectangleCursorPos(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
s8 column;
|
|
|
|
s8 row;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
if (sScreenControl->rectangleCursorSpriteRight
|
2021-02-22 18:12:35 +01:00
|
|
|
&& sScreenControl->rectangleCursorSpriteLeft)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
GetKeyboardCursorColAndRow(&column, &row);
|
|
|
|
if (!GetInAlphabetMode())
|
|
|
|
SetRectangleCursorPos_GroupMode(column, row);
|
2019-02-24 17:04:40 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
SetRectangleCursorPos_AlphabetMode(column, row);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetRectangleCursorPos_GroupMode(s8 column, s8 row)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (column != -1)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// In group name window
|
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteRight, RECTCURSOR_ANIM_ON_GROUP);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->x = column * 84 + 58;
|
|
|
|
sScreenControl->rectangleCursorSpriteRight->y = row * 16 + 96;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteLeft, RECTCURSOR_ANIM_ON_GROUP);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteLeft->x = column * 84 + 58;
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft->y = row * 16 + 96;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// In button window
|
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteRight, RECTCURSOR_ANIM_ON_BUTTON);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->x = 216;
|
|
|
|
sScreenControl->rectangleCursorSpriteRight->y = row * 16 + 112;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteLeft, RECTCURSOR_ANIM_ON_BUTTON);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteLeft->x = 216;
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft->y = row * 16 + 112;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetRectangleCursorPos_AlphabetMode(s8 column, s8 row)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
int anim;
|
|
|
|
int x, y;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (column != -1)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
y = row * 16 + 96;
|
2019-02-24 17:04:40 +01:00
|
|
|
x = 32;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (column == NUM_ALPHABET_COLUMNS - 1 && row == 0)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Cursor is on 'Others'
|
2019-02-24 17:04:40 +01:00
|
|
|
x = 158;
|
2021-02-22 18:12:35 +01:00
|
|
|
anim = RECTCURSOR_ANIM_ON_OTHERS;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Cursor is on a letter
|
|
|
|
x += sAlphabetKeyboardColumnOffsets[(u8)column < NUM_ALPHABET_COLUMNS ? column : 0];
|
|
|
|
anim = RECTCURSOR_ANIM_ON_LETTER;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteRight, anim);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->x = x;
|
|
|
|
sScreenControl->rectangleCursorSpriteRight->y = y;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteLeft, anim);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteLeft->x = x;
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft->y = y;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// In button window
|
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteRight, RECTCURSOR_ANIM_ON_BUTTON);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteRight->x = 216;
|
|
|
|
sScreenControl->rectangleCursorSpriteRight->y = row * 16 + 112;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->rectangleCursorSpriteLeft, RECTCURSOR_ANIM_ON_BUTTON);
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->rectangleCursorSpriteLeft->x = 216;
|
|
|
|
sScreenControl->rectangleCursorSpriteLeft->y = row * 16 + 112;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Cursor for selecting a new word
|
|
|
|
// Identical in appearance to the 'main' cursor
|
|
|
|
static void CreateWordSelectCursorSprite(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_TriangleCursor, 0, 0, 4);
|
|
|
|
sScreenControl->wordSelectCursorSprite = &gSprites[spriteId];
|
|
|
|
sScreenControl->wordSelectCursorSprite->callback = SpriteCB_WordSelectCursor;
|
|
|
|
sScreenControl->wordSelectCursorSprite->oam.priority = 2;
|
|
|
|
UpdateWordSelectCursorPos();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SpriteCB_WordSelectCursor(struct Sprite *sprite)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (++sprite->sDelayTimer > 2)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sprite->sDelayTimer = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (++sprite->x2 > 0)
|
|
|
|
sprite->x2 = -6;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void UpdateWordSelectCursorPos(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
s8 column, row, x, y;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
GetWordSelectColAndRow(&column, &row);
|
|
|
|
x = column * 13;
|
2019-02-24 17:04:40 +01:00
|
|
|
x = x * 8 + 28;
|
2021-02-22 18:12:35 +01:00
|
|
|
y = row * 16 + 96;
|
|
|
|
SetWordSelectCursorPos(x, y);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetWordSelectCursorPos(u8 x, u8 y)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sScreenControl->wordSelectCursorSprite)
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->wordSelectCursorSprite->x = x;
|
|
|
|
sScreenControl->wordSelectCursorSprite->y = y;
|
|
|
|
sScreenControl->wordSelectCursorSprite->x2 = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->wordSelectCursorSprite->sDelayTimer = 0;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
}
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void DestroyWordSelectCursorSprite(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sScreenControl->wordSelectCursorSprite)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroySprite(sScreenControl->wordSelectCursorSprite);
|
|
|
|
sScreenControl->wordSelectCursorSprite = NULL;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void CreateSideWindowSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_ButtonWindow, 208, 128, 6);
|
|
|
|
sScreenControl->buttonWindowSprite = &gSprites[spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->buttonWindowSprite->x2 = -64;
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_ModeWindow, 208, 80, 5);
|
|
|
|
sScreenControl->modeWindowSprite = &gSprites[spriteId];
|
|
|
|
sScreenControl->modeWindowState = 0;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 ShowSideWindow(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->modeWindowState)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
// Slide button window on
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->buttonWindowSprite->x2 += 8;
|
|
|
|
if (sScreenControl->buttonWindowSprite->x2 >= 0)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->buttonWindowSprite->x2 = 0;
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
// Set mode window anim
|
|
|
|
if (!GetInAlphabetMode())
|
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TO_GROUP);
|
2019-02-24 17:04:40 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TO_ALPHABET);
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->modeWindowState++;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sScreenControl->modeWindowSprite->animEnded)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->modeWindowState = 2;
|
2019-02-24 17:04:40 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void HideModeWindow(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->modeWindowState = 0;
|
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TO_HIDDEN);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 DestroySideWindowSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
switch (sScreenControl->modeWindowState)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
case 0:
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sScreenControl->modeWindowSprite->animEnded)
|
|
|
|
sScreenControl->modeWindowState = 1;
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->buttonWindowSprite->x2 -= 8;
|
|
|
|
if (sScreenControl->buttonWindowSprite->x2 <= -64)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
DestroySprite(sScreenControl->modeWindowSprite);
|
|
|
|
DestroySprite(sScreenControl->buttonWindowSprite);
|
|
|
|
sScreenControl->modeWindowSprite = NULL;
|
|
|
|
sScreenControl->buttonWindowSprite = NULL;
|
|
|
|
sScreenControl->modeWindowState++;
|
2019-02-24 17:04:40 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetModeWindowToTransition(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TRANSITION);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void UpdateModeWindowAnim(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!GetInAlphabetMode())
|
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TO_GROUP);
|
2019-02-24 17:04:40 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
StartSpriteAnim(sScreenControl->modeWindowSprite, MODEWINDOW_ANIM_TO_ALPHABET);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsModeWindowAnimActive(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return !sScreenControl->modeWindowSprite->animEnded;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void CreateScrollIndicatorSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_ScrollIndicator, 96, 80, 0);
|
2019-02-24 17:04:40 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollIndicatorUpSprite = &gSprites[spriteId];
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_ScrollIndicator, 96, 156, 0);
|
2019-02-24 17:04:40 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollIndicatorDownSprite = &gSprites[spriteId];
|
|
|
|
sScreenControl->scrollIndicatorDownSprite->vFlip = TRUE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
HideScrollIndicators();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void UpdateScrollIndicatorsVisibility(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollIndicatorUpSprite->invisible = !CanScrollUp();
|
|
|
|
sScreenControl->scrollIndicatorDownSprite->invisible = !CanScrollDown();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void HideScrollIndicators(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->scrollIndicatorUpSprite->invisible = TRUE;
|
|
|
|
sScreenControl->scrollIndicatorDownSprite->invisible = TRUE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetScrollIndicatorXPos(bool32 inWordSelect)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!inWordSelect)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Keyboard (only relevant for group mode, can't scroll in alphabet mode)
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->scrollIndicatorUpSprite->x = 96;
|
|
|
|
sScreenControl->scrollIndicatorDownSprite->x = 96;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
// Word select
|
2021-07-07 15:11:52 +02:00
|
|
|
sScreenControl->scrollIndicatorUpSprite->x = 120;
|
|
|
|
sScreenControl->scrollIndicatorDownSprite->x = 120;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// The Start/Select buttons are used as page scroll indicators
|
|
|
|
static void CreateStartSelectButtonSprites(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_StartSelectButton, 220, 84, 1);
|
2019-02-24 17:04:40 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->startButtonSprite = &gSprites[spriteId];
|
2019-02-24 17:04:40 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_StartSelectButton, 220, 156, 1);
|
2019-02-24 17:04:40 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->selectButtonSprite = &gSprites[spriteId];
|
|
|
|
StartSpriteAnim(sScreenControl->selectButtonSprite, 1);
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
HideStartSelectButtons();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void UpdateStartSelectButtonsVisibility(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->startButtonSprite->invisible = !CanScrollUp();
|
|
|
|
sScreenControl->selectButtonSprite->invisible = !CanScrollDown();
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void HideStartSelectButtons(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sScreenControl->startButtonSprite->invisible = TRUE;
|
|
|
|
sScreenControl->selectButtonSprite->invisible = TRUE;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void TryAddInterviewObjectEvents(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
|
|
|
int graphicsId;
|
|
|
|
u8 spriteId;
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
switch (GetDisplayedPersonType())
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_PERSON_REPORTER_MALE:
|
2019-11-21 05:12:51 +01:00
|
|
|
graphicsId = OBJ_EVENT_GFX_REPORTER_M;
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_PERSON_REPORTER_FEMALE:
|
2019-11-21 05:12:51 +01:00
|
|
|
graphicsId = OBJ_EVENT_GFX_REPORTER_F;
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
2019-02-27 19:45:31 +01:00
|
|
|
case EASY_CHAT_PERSON_BOY:
|
2019-11-21 05:12:51 +01:00
|
|
|
graphicsId = OBJ_EVENT_GFX_BOY_1;
|
2019-02-24 17:04:40 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (GetEasyChatScreenFrameId() != FRAMEID_INTERVIEW_SHOW_PERSON)
|
2019-02-24 17:04:40 +01:00
|
|
|
return;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Add object for reporter/interviewing fan (facing left)
|
2021-11-18 05:28:43 +01:00
|
|
|
spriteId = CreateObjectGraphicsSprite(graphicsId, SpriteCallbackDummy, 76, 40, 0);
|
2019-02-24 17:04:40 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].oam.priority = 0;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], 2);
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Add object for player (facing right)
|
2021-11-18 05:28:43 +01:00
|
|
|
spriteId = CreateObjectGraphicsSprite(
|
2019-11-21 05:12:51 +01:00
|
|
|
gSaveBlock2Ptr->playerGender == MALE ? OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL : OBJ_EVENT_GFX_RIVAL_MAY_NORMAL,
|
2019-02-24 17:04:40 +01:00
|
|
|
SpriteCallbackDummy,
|
|
|
|
52,
|
|
|
|
40,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].oam.priority = 0;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
int GetFooterIndex(void)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
u8 frameId = GetEasyChatScreenFrameId();
|
|
|
|
switch (sPhraseFrameDimensions[frameId].footerId)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
case FOOTER_QUIZ:
|
|
|
|
return FOOTER_QUIZ;
|
|
|
|
case FOOTER_ANSWER:
|
|
|
|
return FOOTER_ANSWER;
|
|
|
|
case FOOTER_NORMAL:
|
|
|
|
return FOOTER_NORMAL;
|
2019-02-24 17:04:40 +01:00
|
|
|
default:
|
2021-02-22 18:12:35 +01:00
|
|
|
return NUM_FOOTER_TYPES;
|
2019-02-24 17:04:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:45:31 +01:00
|
|
|
static int GetFooterOptionXOffset(int option)
|
2019-02-24 17:04:40 +01:00
|
|
|
{
|
2019-02-27 19:45:31 +01:00
|
|
|
int footerIndex = GetFooterIndex();
|
2021-02-22 18:12:35 +01:00
|
|
|
if (footerIndex < NUM_FOOTER_TYPES)
|
2019-02-27 19:45:31 +01:00
|
|
|
return sFooterOptionXOffsets[footerIndex][option] + 4;
|
2019-02-24 17:04:40 +01:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2019-02-25 21:03:13 +01:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void AddMainScreenButtonWindow(void)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u16 windowId;
|
|
|
|
struct WindowTemplate template;
|
2021-02-22 18:12:35 +01:00
|
|
|
int footerIndex = GetFooterIndex();
|
|
|
|
if (footerIndex == NUM_FOOTER_TYPES)
|
2019-02-25 21:03:13 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
template.bg = 3;
|
|
|
|
template.tilemapLeft = 1;
|
|
|
|
template.tilemapTop = 11;
|
|
|
|
template.width = 28;
|
|
|
|
template.height = 2;
|
2022-08-19 17:32:00 +02:00
|
|
|
template.paletteNum = 11;
|
2019-02-25 21:03:13 +01:00
|
|
|
template.baseBlock = 0x34;
|
|
|
|
windowId = AddWindow(&template);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < (int)ARRAY_COUNT(sFooterTextOptions[0]); i++)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
const u8 *str = sFooterTextOptions[footerIndex][i];
|
2019-02-25 21:03:13 +01:00
|
|
|
if (str)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
int x = sFooterOptionXOffsets[footerIndex][i];
|
2021-10-30 22:47:37 +02:00
|
|
|
PrintEasyChatText(windowId, FONT_NORMAL, str, x, 1, 0, NULL);
|
2019-02-25 21:03:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
static bool8 IsEasyChatGroupUnlocked(u8 groupId)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
switch (groupId)
|
|
|
|
{
|
|
|
|
case EC_GROUP_TRENDY_SAYING:
|
|
|
|
return FlagGet(FLAG_SYS_HIPSTER_MEET);
|
|
|
|
case EC_GROUP_EVENTS:
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
|
|
|
return FlagGet(FLAG_SYS_GAME_CLEAR);
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
2019-10-20 22:11:07 +02:00
|
|
|
return EasyChatIsNationalPokedexEnabled();
|
2019-02-25 21:03:13 +01:00
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 EasyChat_GetNumWordsInGroup(u8 groupId)
|
|
|
|
{
|
|
|
|
if (groupId == EC_GROUP_POKEMON)
|
|
|
|
return GetNationalPokedexCount(FLAG_GET_SEEN);
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
if (IsEasyChatGroupUnlocked(groupId))
|
2019-02-25 22:20:00 +01:00
|
|
|
return gEasyChatGroups[groupId].numEnabledWords;
|
|
|
|
|
2019-02-25 21:03:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsEasyChatWordInvalid(u16 easyChatWord)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u8 groupId;
|
|
|
|
u32 index;
|
|
|
|
u16 numWords;
|
|
|
|
const u16 *list;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (easyChatWord == EC_EMPTY_WORD)
|
2019-02-25 21:03:13 +01:00
|
|
|
return FALSE;
|
2019-02-25 22:20:00 +01:00
|
|
|
|
2019-02-25 21:03:13 +01:00
|
|
|
groupId = EC_GROUP(easyChatWord);
|
|
|
|
index = EC_INDEX(easyChatWord);
|
|
|
|
if (groupId >= EC_NUM_GROUPS)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
numWords = gEasyChatGroups[groupId].numWords;
|
|
|
|
switch (groupId)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
2019-02-25 21:03:13 +01:00
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
|
|
|
list = gEasyChatGroups[groupId].wordData.valueList;
|
|
|
|
for (i = 0; i < numWords; i++)
|
|
|
|
{
|
|
|
|
if (index == list[i])
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
|
|
|
|
if (index >= numWords)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
2019-02-25 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 21:42:51 +01:00
|
|
|
bool8 IsBardWordInvalid(u16 easyChatWord)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
int numWordsInGroup;
|
|
|
|
u8 groupId = EC_GROUP(easyChatWord);
|
|
|
|
u32 index = EC_INDEX(easyChatWord);
|
|
|
|
if (groupId >= EC_NUM_GROUPS)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (groupId)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
2021-01-28 21:42:51 +01:00
|
|
|
numWordsInGroup = gNumBardWords_Species;
|
2019-02-25 21:03:13 +01:00
|
|
|
break;
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
2021-01-28 21:42:51 +01:00
|
|
|
numWordsInGroup = gNumBardWords_Moves;
|
2019-02-25 21:03:13 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
numWordsInGroup = gEasyChatGroups[groupId].numWords;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numWordsInGroup <= index)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static const u8 *GetEasyChatWord(u8 groupId, u16 index)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
switch (groupId)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
2019-02-25 21:03:13 +01:00
|
|
|
return gSpeciesNames[index];
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
|
|
|
return gMoveNames[index];
|
|
|
|
default:
|
|
|
|
return gEasyChatGroups[groupId].wordData.words[index].text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *CopyEasyChatWord(u8 *dest, u16 easyChatWord)
|
|
|
|
{
|
|
|
|
u8 *resultStr;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsEasyChatWordInvalid(easyChatWord))
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
resultStr = StringCopy(dest, gText_ThreeQuestionMarks);
|
|
|
|
}
|
2021-02-22 18:12:35 +01:00
|
|
|
else if (easyChatWord != EC_EMPTY_WORD)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u16 index = EC_INDEX(easyChatWord);
|
|
|
|
u8 groupId = EC_GROUP(easyChatWord);
|
|
|
|
resultStr = StringCopy(dest, GetEasyChatWord(groupId, index));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dest = EOS;
|
|
|
|
resultStr = dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows)
|
|
|
|
{
|
|
|
|
u16 i, j;
|
|
|
|
u16 numColumns = columns - 1;
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < numColumns; j++)
|
|
|
|
{
|
|
|
|
dest = CopyEasyChatWord(dest, *src);
|
2021-02-22 18:12:35 +01:00
|
|
|
if (*src != EC_EMPTY_WORD)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
*dest = CHAR_SPACE;
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest = CopyEasyChatWord(dest, *(src++));
|
|
|
|
*dest = CHAR_NEWLINE;
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest--;
|
|
|
|
*dest = EOS;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 *UnusedConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u16 i, j, k;
|
|
|
|
u16 numColumns;
|
2021-02-22 18:12:35 +01:00
|
|
|
int notEmpty, lineNumber;
|
2019-02-25 21:03:13 +01:00
|
|
|
|
|
|
|
numColumns = columns;
|
2021-02-22 18:12:35 +01:00
|
|
|
lineNumber = 0;
|
2019-02-25 21:03:13 +01:00
|
|
|
columns--;
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
const u16 *str = src;
|
|
|
|
notEmpty = FALSE;
|
2019-02-25 21:03:13 +01:00
|
|
|
for (j = 0; j < numColumns; j++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (str[j] != EC_EMPTY_WORD)
|
|
|
|
notEmpty = TRUE;
|
2019-02-25 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!notEmpty)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
src += numColumns;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k = 0; k < columns; k++)
|
|
|
|
{
|
|
|
|
dest = CopyEasyChatWord(dest, *src);
|
2021-02-22 18:12:35 +01:00
|
|
|
if (*src != EC_EMPTY_WORD)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
*dest = CHAR_SPACE;
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest = CopyEasyChatWord(dest, *(src++));
|
2021-02-22 18:12:35 +01:00
|
|
|
if (lineNumber == 0)
|
2019-02-25 21:03:13 +01:00
|
|
|
*dest = CHAR_NEWLINE;
|
|
|
|
else
|
|
|
|
*dest = CHAR_PROMPT_SCROLL;
|
|
|
|
|
|
|
|
dest++;
|
2021-02-22 18:12:35 +01:00
|
|
|
lineNumber++;
|
2019-02-25 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dest--;
|
|
|
|
*dest = EOS;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u16 GetEasyChatWordStringLength(u16 easyChatWord)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (easyChatWord == EC_EMPTY_WORD)
|
2019-02-25 21:03:13 +01:00
|
|
|
return 0;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsEasyChatWordInvalid(easyChatWord))
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
return StringLength(gText_ThreeQuestionMarks);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u16 index = EC_INDEX(easyChatWord);
|
|
|
|
u8 groupId = EC_GROUP(easyChatWord);
|
|
|
|
return StringLength(GetEasyChatWord(groupId, index));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
static bool8 CanPhraseFitInXRowsYCols(const u16 *easyChatWords, u8 numRows, u8 numColumns, u16 maxLength)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u8 i, j;
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
for (i = 0; i < numColumns; i++)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
2020-01-08 21:26:14 +01:00
|
|
|
u16 totalLength = numRows - 1;
|
|
|
|
for (j = 0; j < numRows; j++)
|
2019-02-25 21:03:13 +01:00
|
|
|
totalLength += GetEasyChatWordStringLength(*(easyChatWords++));
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
if (totalLength > maxLength)
|
2019-02-25 21:03:13 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
u16 GetRandomEasyChatWordFromGroup(u16 groupId)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u16 index = Random() % gEasyChatGroups[groupId].numWords;
|
|
|
|
if (groupId == EC_GROUP_POKEMON
|
2021-02-22 18:12:35 +01:00
|
|
|
|| groupId == EC_GROUP_POKEMON_NATIONAL
|
2019-02-25 21:03:13 +01:00
|
|
|
|| groupId == EC_GROUP_MOVE_1
|
|
|
|
|| groupId == EC_GROUP_MOVE_2)
|
|
|
|
{
|
|
|
|
index = gEasyChatGroups[groupId].wordData.valueList[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
return EC_WORD(groupId, index);
|
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
u16 GetRandomEasyChatWordFromUnlockedGroup(u16 groupId)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
if (!IsEasyChatGroupUnlocked(groupId))
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-25 21:03:13 +01:00
|
|
|
|
|
|
|
if (groupId == EC_GROUP_POKEMON)
|
2020-01-08 21:26:14 +01:00
|
|
|
return GetRandomUnlockedEasyChatPokemon();
|
2019-02-25 21:03:13 +01:00
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
return GetRandomEasyChatWordFromGroup(groupId);
|
2019-02-25 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
void ShowEasyChatProfile(void)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u16 *easyChatWords;
|
|
|
|
int columns, rows;
|
|
|
|
switch (gSpecialVar_0x8004)
|
|
|
|
{
|
|
|
|
case 0:
|
2019-02-27 19:45:31 +01:00
|
|
|
easyChatWords = gSaveBlock1Ptr->easyChatProfile;
|
2019-02-25 21:03:13 +01:00
|
|
|
columns = 2;
|
|
|
|
rows = 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-02-27 19:45:31 +01:00
|
|
|
easyChatWords = gSaveBlock1Ptr->easyChatBattleStart;
|
2020-01-08 21:26:14 +01:00
|
|
|
if (CanPhraseFitInXRowsYCols(gSaveBlock1Ptr->easyChatBattleStart, 3, 2, 18))
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
columns = 2;
|
|
|
|
rows = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
columns = 3;
|
|
|
|
rows = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-02-27 19:45:31 +01:00
|
|
|
easyChatWords = gSaveBlock1Ptr->easyChatBattleWon;
|
2019-02-25 21:03:13 +01:00
|
|
|
columns = 3;
|
|
|
|
rows = 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-02-27 19:45:31 +01:00
|
|
|
easyChatWords = gSaveBlock1Ptr->easyChatBattleLost;
|
2019-02-25 21:03:13 +01:00
|
|
|
columns = 3;
|
|
|
|
rows = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConvertEasyChatWordsToString(gStringVar4, easyChatWords, columns, rows);
|
|
|
|
ShowFieldAutoScrollMessage(gStringVar4);
|
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
// The phrase that a man in Dewford Hall suggests has a "deep link" to the current trendy phrase
|
|
|
|
void BufferDeepLinkPhrase(void)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
int groupId = Random() & 1 ? EC_GROUP_HOBBIES : EC_GROUP_LIFESTYLE;
|
2020-01-08 21:26:14 +01:00
|
|
|
u16 easyChatWord = GetRandomEasyChatWordFromUnlockedGroup(groupId);
|
2019-02-25 21:03:13 +01:00
|
|
|
CopyEasyChatWord(gStringVar2, easyChatWord);
|
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
static bool8 IsAdditionalPhraseUnlocked(u8 additionalPhraseId)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
int byteOffset = additionalPhraseId / 8;
|
2019-02-26 18:17:41 +01:00
|
|
|
int shift = additionalPhraseId % 8;
|
2019-02-25 21:03:13 +01:00
|
|
|
return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1;
|
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
void UnlockAdditionalPhrase(u8 additionalPhraseId)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
if (additionalPhraseId < NUM_ADDITIONAL_PHRASES)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
int byteOffset = additionalPhraseId / 8;
|
2019-02-26 18:17:41 +01:00
|
|
|
int shift = additionalPhraseId % 8;
|
2019-02-25 21:03:13 +01:00
|
|
|
gSaveBlock1Ptr->additionalPhrases[byteOffset] |= 1 << shift;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
static u8 GetNumAdditionalPhrasesUnlocked(void)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 numAdditionalPhrasesUnlocked;
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
for (i = 0, numAdditionalPhrasesUnlocked = 0; i < NUM_ADDITIONAL_PHRASES; i++)
|
2019-02-25 21:03:13 +01:00
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
if (IsAdditionalPhraseUnlocked(i))
|
2019-02-25 21:03:13 +01:00
|
|
|
numAdditionalPhrasesUnlocked++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return numAdditionalPhrasesUnlocked;
|
|
|
|
}
|
2019-02-26 18:17:41 +01:00
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
u16 GetNewHipsterPhraseToTeach(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 additionalPhraseId;
|
2019-10-20 22:11:07 +02:00
|
|
|
u8 numAdditionalPhrasesUnlocked = GetNumAdditionalPhrasesUnlocked();
|
|
|
|
if (numAdditionalPhrasesUnlocked == NUM_ADDITIONAL_PHRASES)
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
additionalPhraseId = Random() % (NUM_ADDITIONAL_PHRASES - numAdditionalPhrasesUnlocked);
|
|
|
|
for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
if (!IsAdditionalPhraseUnlocked(i))
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
if (additionalPhraseId)
|
|
|
|
{
|
|
|
|
additionalPhraseId--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
UnlockAdditionalPhrase(i);
|
2019-02-26 18:17:41 +01:00
|
|
|
return EC_WORD(EC_GROUP_TRENDY_SAYING, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
// Unused
|
|
|
|
u16 GetRandomTaughtHipsterPhrase(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-10-20 22:11:07 +02:00
|
|
|
u16 additionalPhraseId = GetNumAdditionalPhrasesUnlocked();
|
2019-02-26 18:17:41 +01:00
|
|
|
if (additionalPhraseId == 0)
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
|
|
|
|
additionalPhraseId = Random() % additionalPhraseId;
|
2019-10-20 22:11:07 +02:00
|
|
|
for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2019-10-20 22:11:07 +02:00
|
|
|
if (IsAdditionalPhraseUnlocked(i))
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
if (additionalPhraseId)
|
|
|
|
additionalPhraseId--;
|
|
|
|
else
|
|
|
|
return EC_WORD(EC_GROUP_TRENDY_SAYING, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2019-10-20 22:11:07 +02:00
|
|
|
static bool8 EasyChatIsNationalPokedexEnabled(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
return IsNationalPokedexEnabled();
|
|
|
|
}
|
|
|
|
|
2020-01-08 21:26:14 +01:00
|
|
|
static u16 GetRandomUnlockedEasyChatPokemon(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 numWords;
|
|
|
|
const u16 *species;
|
|
|
|
u16 index = EasyChat_GetNumWordsInGroup(EC_GROUP_POKEMON);
|
|
|
|
if (index == 0)
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
|
|
|
|
index = Random() % index;
|
|
|
|
species = gEasyChatGroups[EC_GROUP_POKEMON].wordData.valueList;
|
|
|
|
numWords = gEasyChatGroups[EC_GROUP_POKEMON].numWords;
|
|
|
|
for (i = 0; i < numWords; i++)
|
|
|
|
{
|
|
|
|
u16 dexNum = SpeciesToNationalPokedexNum(*species);
|
|
|
|
if (GetSetPokedexFlag(dexNum, FLAG_GET_SEEN))
|
|
|
|
{
|
|
|
|
if (index)
|
|
|
|
index--;
|
|
|
|
else
|
|
|
|
return EC_WORD(EC_GROUP_POKEMON, *species);
|
|
|
|
}
|
|
|
|
|
|
|
|
species++;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitEasyChatPhrases(void)
|
|
|
|
{
|
|
|
|
u16 i, j;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sDefaultProfileWords); i++)
|
2019-02-27 19:45:31 +01:00
|
|
|
gSaveBlock1Ptr->easyChatProfile[i] = sDefaultProfileWords[i];
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
|
2019-02-27 19:45:31 +01:00
|
|
|
gSaveBlock1Ptr->easyChatBattleStart[i] = sDefaultBattleStartWords[i];
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
|
|
|
|
gSaveBlock1Ptr->easyChatBattleWon[i] = sDefaultBattleWonWords[i];
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
|
|
|
|
gSaveBlock1Ptr->easyChatBattleLost[i] = sDefaultBattleLostWords[i];
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-02-26 18:17:41 +01:00
|
|
|
for (i = 0; i < MAIL_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < MAIL_WORDS_COUNT; j++)
|
2021-02-22 18:12:35 +01:00
|
|
|
gSaveBlock1Ptr->mail[i].words[j] = EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2020-05-09 14:49:51 +02:00
|
|
|
#ifndef UBFIX
|
2019-02-26 18:17:41 +01:00
|
|
|
// BUG: This is supposed to clear 64 bits, but this loop is clearing 64 bytes.
|
|
|
|
// However, this bug has no resulting effect on gameplay because only the
|
|
|
|
// Mauville old man data is corrupted, which is initialized directly after
|
|
|
|
// this function is called when starting a new game.
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
gSaveBlock1Ptr->additionalPhrases[i] = 0;
|
2020-05-09 14:49:51 +02:00
|
|
|
#else
|
|
|
|
for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->additionalPhrases); i++)
|
|
|
|
gSaveBlock1Ptr->additionalPhrases[i] = 0;
|
|
|
|
#endif
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 InitEasyChatScreenWordData(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData = Alloc(sizeof(*sWordData));
|
|
|
|
if (!sWordData)
|
2019-02-26 18:17:41 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
SetUnlockedEasyChatGroups();
|
|
|
|
SetUnlockedWordsByAlphabet();
|
2019-02-26 18:17:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void FreeEasyChatScreenWordData(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2022-06-03 16:42:53 +02:00
|
|
|
TRY_FREE_AND_SET_NULL(sWordData);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetUnlockedEasyChatGroups(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->numUnlockedGroups = 0;
|
2019-02-26 18:17:41 +01:00
|
|
|
if (GetNationalPokedexCount(FLAG_GET_SEEN))
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_POKEMON;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// These groups are unlocked automatically
|
2019-02-26 18:17:41 +01:00
|
|
|
for (i = EC_GROUP_TRAINER; i <= EC_GROUP_ADJECTIVES; i++)
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = i;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-02-26 18:17:41 +01:00
|
|
|
if (FlagGet(FLAG_SYS_GAME_CLEAR))
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_EVENTS;
|
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_MOVE_1;
|
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_MOVE_2;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FlagGet(FLAG_SYS_HIPSTER_MEET))
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_TRENDY_SAYING;
|
2019-02-26 18:17:41 +01:00
|
|
|
|
|
|
|
if (IsNationalPokedexEnabled())
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_POKEMON_NATIONAL;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetNumUnlockedEasyChatGroups(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sWordData->numUnlockedGroups;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 GetUnlockedEasyChatGroupId(u8 index)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (index >= sWordData->numUnlockedGroups)
|
2019-02-26 18:17:41 +01:00
|
|
|
return EC_NUM_GROUPS;
|
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return sWordData->unlockedGroupIds[index];
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Unused
|
|
|
|
static u8 *BufferEasyChatWordGroupName(u8 *dest, u8 groupId, u16 totalChars)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-02-22 18:12:35 +01:00
|
|
|
u8 *str = StringCopy(dest, sEasyChatGroupNamePointers[groupId]);
|
2019-02-26 18:17:41 +01:00
|
|
|
for (i = str - dest; i < totalChars; i++)
|
|
|
|
{
|
|
|
|
*str = CHAR_SPACE;
|
|
|
|
str++;
|
|
|
|
}
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-02-26 18:17:41 +01:00
|
|
|
*str = EOS;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u8 *GetEasyChatWordGroupName(u8 groupId)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sEasyChatGroupNamePointers[groupId];
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 *CopyEasyChatWordPadded(u8 *dest, u16 easyChatWord, u16 totalChars)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u8 *str = CopyEasyChatWord(dest, easyChatWord);
|
|
|
|
for (i = str - dest; i < totalChars; i++)
|
|
|
|
{
|
|
|
|
*str = CHAR_SPACE;
|
|
|
|
str++;
|
|
|
|
}
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-02-26 18:17:41 +01:00
|
|
|
*str = EOS;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetUnlockedWordsByAlphabet(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
int i, j, k;
|
|
|
|
int numWords;
|
|
|
|
const u16 *words;
|
|
|
|
u16 numToProcess;
|
|
|
|
int index;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < EC_NUM_ALPHABET_GROUPS; i++)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
numWords = gEasyChatWordsByLetterPointers[i].numWords;
|
|
|
|
words = gEasyChatWordsByLetterPointers[i].words;
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->numUnlockedAlphabetWords[i] = 0;
|
2019-02-26 18:17:41 +01:00
|
|
|
index = 0;
|
|
|
|
for (j = 0; j < numWords; j++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (*words == EC_EMPTY_WORD)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
words++;
|
|
|
|
numToProcess = *words;
|
|
|
|
words++;
|
|
|
|
j += 1 + numToProcess;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numToProcess = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k = 0; k < numToProcess; k++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsEasyChatWordUnlocked(words[k]))
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->unlockedAlphabetWords[i][index++] = words[k];
|
|
|
|
sWordData->numUnlockedAlphabetWords[i]++;
|
2019-02-26 18:17:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
words += numToProcess;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static void SetSelectedWordGroup(bool32 inAlphabetMode, u16 groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!inAlphabetMode)
|
|
|
|
sWordData->numSelectedGroupWords = SetSelectedWordGroup_GroupMode(groupId);
|
2019-02-26 18:17:41 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
sWordData->numSelectedGroupWords = SetSelectedWordGroup_AlphabetMode(groupId);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 GetWordFromSelectedGroup(u16 index)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (index >= sWordData->numSelectedGroupWords)
|
|
|
|
return EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return sWordData->selectedGroupWords[index];
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 GetNumWordsInSelectedGroup(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
return sWordData->numSelectedGroupWords;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 SetSelectedWordGroup_GroupMode(u16 groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
int totalWords;
|
|
|
|
const u16 *list;
|
|
|
|
const struct EasyChatWordInfo *wordInfo;
|
|
|
|
u16 numWords = gEasyChatGroups[groupId].numWords;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
if (groupId == EC_GROUP_POKEMON || groupId == EC_GROUP_POKEMON_NATIONAL
|
2019-02-26 18:17:41 +01:00
|
|
|
|| groupId == EC_GROUP_MOVE_1 || groupId == EC_GROUP_MOVE_2)
|
|
|
|
{
|
|
|
|
list = gEasyChatGroups[groupId].wordData.valueList;
|
|
|
|
for (i = 0, totalWords = 0; i < numWords; i++)
|
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsEasyChatIndexAndGroupUnlocked(list[i], groupId))
|
|
|
|
sWordData->selectedGroupWords[totalWords++] = EC_WORD(groupId, list[i]);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return totalWords;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wordInfo = gEasyChatGroups[groupId].wordData.words;
|
|
|
|
for (i = 0, totalWords = 0; i < numWords; i++)
|
|
|
|
{
|
|
|
|
u16 alphabeticalOrder = wordInfo[i].alphabeticalOrder;
|
2021-02-22 18:12:35 +01:00
|
|
|
if (IsEasyChatIndexAndGroupUnlocked(alphabeticalOrder, groupId))
|
|
|
|
sWordData->selectedGroupWords[totalWords++] = EC_WORD(groupId, alphabeticalOrder);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return totalWords;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u16 SetSelectedWordGroup_AlphabetMode(u16 groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 totalWords;
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0, totalWords = 0; i < sWordData->numUnlockedAlphabetWords[groupId]; i++)
|
|
|
|
sWordData->selectedGroupWords[totalWords++] = sWordData->unlockedAlphabetWords[groupId][i];
|
2019-02-26 18:17:41 +01:00
|
|
|
|
|
|
|
return totalWords;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsEasyChatGroupUnlocked2(u8 groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < sWordData->numUnlockedGroups; i++)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sWordData->unlockedGroupIds[i] == groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static bool8 IsEasyChatIndexAndGroupUnlocked(u16 wordIndex, u8 groupId)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
switch (groupId)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
|
|
|
return GetSetPokedexFlag(SpeciesToNationalPokedexNum(wordIndex), FLAG_GET_SEEN);
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
|
|
|
if (IsRestrictedWordSpecies(wordIndex))
|
2019-02-26 18:17:41 +01:00
|
|
|
GetSetPokedexFlag(SpeciesToNationalPokedexNum(wordIndex), FLAG_GET_SEEN);
|
|
|
|
return TRUE;
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
|
|
|
return TRUE;
|
|
|
|
case EC_GROUP_TRENDY_SAYING:
|
2019-10-20 22:11:07 +02:00
|
|
|
return IsAdditionalPhraseUnlocked(wordIndex);
|
2019-02-26 18:17:41 +01:00
|
|
|
default:
|
|
|
|
return gEasyChatGroups[groupId].wordData.words[wordIndex].enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
// Pokémon words in EC_GROUP_POKEMON_NATIONAL are always allowed (assuming the group is unlocked)
|
|
|
|
// unless they are in this group. If they are in this group (just Deoxys), they must also have been seen.
|
|
|
|
static int IsRestrictedWordSpecies(u16 species)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sRestrictedWordSpecies); i++)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
2021-02-22 18:12:35 +01:00
|
|
|
if (sRestrictedWordSpecies[i] == species)
|
2019-02-26 18:17:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
static u8 IsEasyChatWordUnlocked(u16 easyChatWord)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
u8 groupId = EC_GROUP(easyChatWord);
|
|
|
|
u32 index = EC_INDEX(easyChatWord);
|
2021-02-22 18:12:35 +01:00
|
|
|
if (!IsEasyChatGroupUnlocked2(groupId))
|
2019-02-26 18:17:41 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return IsEasyChatIndexAndGroupUnlocked(index, groupId);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitializeEasyChatWordArray(u16 *words, u16 length)
|
|
|
|
{
|
|
|
|
u16 i;
|
2021-02-22 18:12:35 +01:00
|
|
|
for (i = length - 1; i != EC_EMPTY_WORD; i--)
|
|
|
|
*(words++) = EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
void InitQuestionnaireWords(void)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-22 18:12:35 +01:00
|
|
|
u16 *words = GetQuestionnaireWordsPtr();
|
|
|
|
for (i = 0; i < NUM_QUESTIONNAIRE_WORDS; i++)
|
|
|
|
words[i] = EC_EMPTY_WORD;
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 18:12:35 +01:00
|
|
|
bool32 IsEasyChatAnswerUnlocked(int easyChatWord)
|
2019-02-26 18:17:41 +01:00
|
|
|
{
|
|
|
|
int groupId = EC_GROUP(easyChatWord);
|
2021-02-22 18:12:35 +01:00
|
|
|
int mask = EC_MASK_GROUP;
|
2019-02-26 18:17:41 +01:00
|
|
|
int index = EC_INDEX(easyChatWord);
|
2019-10-20 22:11:07 +02:00
|
|
|
if (!IsEasyChatGroupUnlocked(groupId & mask))
|
2019-02-26 18:17:41 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
2021-02-22 18:12:35 +01:00
|
|
|
return IsEasyChatIndexAndGroupUnlocked(index, groupId & mask);
|
2019-02-26 18:17:41 +01:00
|
|
|
}
|