[Feature] Implement Joker descriptions in the Shop when holding B (#530)
* WIP * WIP * WIP * WIP * Tags are bugged but it's looking good * Centering is bugged, almost there * WIP * Fixed centeriiiing, yaaaay * good progress * add proper '\n' support * WIP descriptions * All descriptions are there ^^ * missing 9-patch for pretty display * WIP * fix rebase issues * Fix minor Run Setup screen issues * Almost done, only one fix to go * Aaaalmooost doooneeeee * make desc frame size adaptative * add rarity color and text * final cleanup * clang format * clang format * clang format * clang format * clang format * Fix Joker update loop index * Fix const and Bull description * Fix unwanted button SFX * fix tte colors * Add misprint description * Fix justified line length computation * Add safeguards to tag parsing loop * clang format * Fix Ante bugged display at boss blind end * Tweak suit colors * Final fixes * Simplified the way we print descriptions * simplify further * get rid of weird macro * Fix Onwed joker price when holding A after showing its description --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
This commit is contained in:
+130
-5
@@ -63,20 +63,32 @@
|
||||
/** @def TTE_BIT_ON_CLR_IDX */
|
||||
#define TTE_BIT_ON_CLR_IDX TTE_BIT_UNPACK_OFFSET + 1
|
||||
|
||||
/** @def TTE_GREEN_PB */
|
||||
#define TTE_GREEN_PB 6 // 0x6
|
||||
|
||||
/** @def TTE_PURPLE_PB */
|
||||
#define TTE_PURPLE_PB 7 // 0x7
|
||||
|
||||
/** @def TTE_DARK_GREEN_PB */
|
||||
#define TTE_DARK_GREEN_PB 8 // 0x8
|
||||
|
||||
/** @def TTE_DARK_BLUE_PB */
|
||||
#define TTE_DARK_BLUE_PB 9 // 0x9
|
||||
|
||||
/** @def TTE_BLACK_PB */
|
||||
#define TTE_BLACK_PB 0 // 0x0
|
||||
#define TTE_BLACK_PB 10 // 0xA
|
||||
|
||||
/** @def TTE_YELLOW_PB */
|
||||
#define TTE_YELLOW_PB 12 // 0xC
|
||||
#define TTE_YELLOW_PB 11 // 0xB
|
||||
|
||||
/** @def TTE_BLUE_PB */
|
||||
#define TTE_BLUE_PB 13 // 0xD
|
||||
#define TTE_BLUE_PB 12 // 0xC
|
||||
|
||||
/** @def TTE_RED_PB */
|
||||
#define TTE_RED_PB 14 // 0xE
|
||||
#define TTE_RED_PB 13 // 0xD
|
||||
|
||||
/** @def TTE_WHITE_PB */
|
||||
#define TTE_WHITE_PB 15 // 0xF
|
||||
#define TTE_WHITE_PB 14 // 0xE
|
||||
|
||||
/** @def TTE_SPECIAL_PB_MULT_OFFSET */
|
||||
#define TTE_SPECIAL_PB_MULT_OFFSET 0x1000
|
||||
@@ -90,12 +102,74 @@
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name TTE Text formatting Tags
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @def TTE_GREEN_TAG */
|
||||
#define TTE_GREEN_TAG "#{cx:0x6000}"
|
||||
|
||||
/** @def TTE_PURPLE_TAG */
|
||||
#define TTE_PURPLE_TAG "#{cx:0x7000}"
|
||||
|
||||
/** @def TTE_GREEN_TAG */
|
||||
#define TTE_DARK_GREEN_TAG "#{cx:0x8000}"
|
||||
|
||||
/** @def TTE_PURPLE_TAG */
|
||||
#define TTE_DARK_BLUE_TAG "#{cx:0x9000}"
|
||||
|
||||
/** @def TTE_BLACK_TAG */
|
||||
#define TTE_BLACK_TAG "#{cx:0xA000}"
|
||||
|
||||
/** @def TTE_YELLOW_TAG */
|
||||
#define TTE_YELLOW_TAG "#{cx:0xB000}"
|
||||
|
||||
/** @def TTE_BLUE_TAG */
|
||||
#define TTE_BLUE_TAG "#{cx:0xC000}"
|
||||
|
||||
/** @def TTE_RED_TAG */
|
||||
#define TTE_RED_TAG "#{cx:0xD000}"
|
||||
|
||||
/** @def TTE_WHITE_TAG */
|
||||
#define TTE_WHITE_TAG "#{cx:0xE000}"
|
||||
|
||||
/** @def TTE_DIAMOND_TAG */
|
||||
#define TTE_DIAMOND_TAG TTE_YELLOW_TAG "Diamond "
|
||||
|
||||
/** @def TTE_HEART_TAG */
|
||||
#define TTE_HEART_TAG TTE_RED_TAG "Hearts "
|
||||
|
||||
/** @def TTE_SPADE_TAG */
|
||||
#define TTE_SPADE_TAG TTE_DARK_BLUE_TAG "Spade "
|
||||
|
||||
/** @def TTE_CLUB_TAG */
|
||||
#define TTE_CLUB_TAG TTE_DARK_GREEN_TAG "Club "
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Text colors
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @def TEXT_CLR_GREEN */
|
||||
#define TEXT_CLR_GREEN RGB15(10, 27, 16)
|
||||
|
||||
/** @def TEXT_CLR_PURPLE */
|
||||
#define TEXT_CLR_PURPLE RGB15(25, 15, 31)
|
||||
|
||||
/** @def TEXT_CLR_DARK_GREEN */
|
||||
#define TEXT_CLR_DARK_GREEN RGB15(0, 14, 8)
|
||||
|
||||
/** @def TEXT_CLR_DARK_BLUE */
|
||||
#define TEXT_CLR_DARK_BLUE RGB15(10, 5, 15)
|
||||
|
||||
/** @def TEXT_CLR_BLACK */
|
||||
#define TEXT_CLR_BLACK RGB15(3, 5, 5) // ~ 0x1483
|
||||
|
||||
/** @def TEXT_CLR_YELLOW */
|
||||
#define TEXT_CLR_YELLOW RGB15(31, 20, 0) // 0x029F
|
||||
|
||||
@@ -147,6 +221,12 @@ enum OverflowDir
|
||||
OVERFLOW_RIGHT = SCREEN_RIGHT
|
||||
};
|
||||
|
||||
enum TextJustifyFlag
|
||||
{
|
||||
JUSTIFY_LEFT,
|
||||
JUSTIFY_CENTER
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
// When making this, missed that it already exists in tonc_math.h
|
||||
@@ -183,6 +263,19 @@ typedef struct NinePatchRect
|
||||
Rect margins;
|
||||
} NinePatchRect;
|
||||
|
||||
INLINE void tte_colors_setup(void)
|
||||
{
|
||||
pal_bg_bank[TTE_GREEN_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_GREEN;
|
||||
pal_bg_bank[TTE_PURPLE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_PURPLE;
|
||||
pal_bg_bank[TTE_DARK_GREEN_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_DARK_GREEN;
|
||||
pal_bg_bank[TTE_DARK_BLUE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_DARK_BLUE;
|
||||
pal_bg_bank[TTE_BLACK_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_BLACK;
|
||||
pal_bg_bank[TTE_YELLOW_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_YELLOW;
|
||||
pal_bg_bank[TTE_BLUE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_BLUE;
|
||||
pal_bg_bank[TTE_RED_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_RED;
|
||||
pal_bg_bank[TTE_WHITE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the width of a rectangle
|
||||
*
|
||||
@@ -422,4 +515,36 @@ void toggle_windows(bool win0, bool win1);
|
||||
*/
|
||||
void reset_top_left_panel_bottom_row(void);
|
||||
|
||||
/**
|
||||
* @brief Justify a text with custom formatting tags according to the given
|
||||
* justification and bias direction tags
|
||||
*
|
||||
* - The raw_text will be divided into Words, separated by 1 space, and 1 space only.
|
||||
* - Each Word can have one or more formatting `{TAGS}` attached to it, and they MUST be right
|
||||
* next to each other. It might not apply correctly otherwise if the line wraps.
|
||||
* - `{TAGS}` must be one of TTE_BLACK_TAG, TTE_YELLOW_TAG, etc.
|
||||
*
|
||||
* @param raw_text The unformatted text. The '\n' character and custom formatting `{TAGS}` will
|
||||
* not count towards the computed line widths, as they won't appear on screen.
|
||||
* @param dst_rect Rectangle the justified text must fit into. Will overflow at the bottom if
|
||||
* text is too long. Size in tiles
|
||||
* @param justify_direction Align the text either to the left or center.
|
||||
* @param bias_direction Used with `JUSTIFY_CENTER` only. Determines if lines that cannot be
|
||||
* centered are to be slightly to the left or to the right.
|
||||
* @param do_print does not actually print anything, only does the calculations to determine
|
||||
* the number of lines taken by the paragraph
|
||||
*
|
||||
* @returns the number of lines the wrapped paragraph takes
|
||||
*
|
||||
* @sa update_text_rect_to_center_str
|
||||
* @sa TTE_BLACK_TAG
|
||||
*/
|
||||
int tte_printf_justified_in_rect(
|
||||
const char* raw_text,
|
||||
Rect dst_rect,
|
||||
enum TextJustifyFlag justify_direction,
|
||||
enum ScreenHorzDir bias_direction,
|
||||
bool do_print
|
||||
);
|
||||
|
||||
#endif // GRAPHIC_UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user