diff options
author | Josh <32826900+ShinyDragonHunter@users.noreply.github.com> | 2020-12-22 18:39:10 +0000 |
---|---|---|
committer | Josh <32826900+ShinyDragonHunter@users.noreply.github.com> | 2020-12-22 18:39:10 +0000 |
commit | b8cccc824023c31f21747362c81a381ce9830c9b (patch) | |
tree | b6eacacb7548b10f1558d4ca3cc0095fad141fb0 /Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md | |
parent | 9890318b658902505f745312f5eb78d8da02fc77 (diff) |
Updated Implementing the “textcolor” script command from FRLG and give object events their own text colour (markdown)
Diffstat (limited to 'Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md')
-rw-r--r-- | Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md b/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md index 2ad026e..516db4e 100644 --- a/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md +++ b/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md @@ -27,7 +27,7 @@ u8 ContextNpcGetTextColor(void) } } ``` -This function is what handles the context of the text. The `if (gSpecialVar_TextColor; != 0xFF)` if I’m honest I’m not sure what it does as of writing this. The else if check looks for the selected object event. This is 0 when interacting with signs or any other text that hasn’t been triggered by the player interacting with an object event. What we need to be paying attention to is the `gSpecialVar_TextColor = graphicsInfo->textColor;`. This is how the function gets the object event text colour. +This function is what handles the context of the text. The `if (gSpecialVar_TextColor; != 0xFF)`… if I’m honest, I’m not sure what it does as of writing this. I think it looks for values that aren’t FF, if the value is FF, that particular snippet won’t do anything. The else if check looks for the selected object event. This is 0 when interacting with signs or any other text that hasn’t been triggered by the player interacting with an object event. What we need to be paying attention to is the `gSpecialVar_TextColor = graphicsInfo->textColor;`. This is how the function gets the object event text colour. Extern it somewhere in `include/field_specials.h` like so: ```c @@ -44,7 +44,7 @@ void AddTextPrinterForMessageWithTextColor(bool8 allowSkippingDelayWithButtonPre gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; color = ContextNpcGetTextColor(); - AddTextPrinterParameterized2(0, 2, gStringVar4, GetPlayerTextSpeedDelay(), NULL, gSpecialVar_TextColor, 1, 3); + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), NULL, gSpecialVar_TextColor, 1, 3); } ``` I put this above `AddTextPrinterForMessage` which is the function base Emerald uses. @@ -60,13 +60,17 @@ We need to open `field_message_box.c` and find the function `StartDrawFieldMessa +```c static void StartDrawFieldMessage(void) { --AddTextPrinterForMessage(TRUE); -+AddTextPrinterForMessageWithTextColor(TRUE); +- AddTextPrinterForMessage(TRUE); ++ AddTextPrinterForMessageWithTextColor(TRUE); CreateTask_DrawFieldMessage(); } +``` + +`StartDrawFieldMessage` is the function that handles message boxes in the overworld. Next, we want to open `field_control_avatar.c` go to the function `ProcessPlayerFieldInput` and make the following change: ```diff @@ -185,16 +189,18 @@ extern u16 gSpecialVar_MonBoxId; extern u16 gSpecialVar_MonBoxPos; - extern u16 gSpecialVar_Unused_0x8014; + extern u16 gSpecialVar_TextColor; -+extern u16; gSpecialVar_PrevTextColor; ++ extern u16; gSpecialVar_PrevTextColor; ``` We need to define them to constants because `PrevTextColor` and `TextColor` can be used in scripts. So we need to go to `include/constants/vars` and find `#define VAR_UNUSED_0x08014` with `#define VAR_TEXT_COLOR` and add a new constant. The changes should look something like this: ```diff - #define VAR_UNUSED_08014 0x0814 -+ #define VAR_TEXT_COLOR 0x8014 ++ #define VAR_TEXT_COLOR 0x8014 #define VAR_TRAINER_BATTLE_OPPONENT_A 0x8015 // Alias of gTrainerBattleOpponent_A -+ #define VAR_PREV_TEXT_COLOR 0x8016 ++ #define VAR_PREV_TEXT_COLOR 0x8016 + +- #define SPECIAL_VARS_END 0x8015 ++ #define SPECIAL_VARS_END 0x8016 +``` -- #define SPECIAL_VARS_END 0x8015 -+ #define SPECIAL_VARS_END 0x8016 -```
\ No newline at end of file +And with that, you should have successfully reimplemented `textcolor` and gave object events their own text colour.
\ No newline at end of file |