diff --git a/graphics/background_gfx.png b/graphics/background_gfx.png index c91b48c..3b3f10d 100644 Binary files a/graphics/background_gfx.png and b/graphics/background_gfx.png differ diff --git a/source/game.c b/source/game.c index e34818c..6a38ce3 100644 --- a/source/game.c +++ b/source/game.c @@ -87,6 +87,7 @@ #define TM_BLIND_SELECT_START 1 #define TM_END_ANIM_SEQ 12 +// TODO: Rename "PID" to "PAL_IDX" // Palette IDs #define BOSS_BLIND_PRIMARY_PID 1 #define MAIN_MENU_PLAY_BUTTON_OUTLINE_PID 2 @@ -96,14 +97,10 @@ #define NEXT_ROUND_BTN_SELECTED_BORDER_PID 5 #define BLIND_BG_SHADOW_PID 5 #define SHOP_PANEL_SHADOW_PID 6 -#define PLAY_HAND_BTN_PID 6 #define BOSS_BLIND_SHADOW_PID 7 -#define PLAY_HAND_BTN_BORDER_PID 7 #define REROLL_BTN_SELECTED_BORDER_PID 7 #define SHOP_LIGHTS_1_PID 8 -#define DISCARD_BTN_BORDER_PID 8 #define BLIND_SKIP_BTN_SELECTED_BORDER_PID 10 -#define DISCARD_BTN_PID 13 #define SHOP_LIGHTS_2_PID 14 #define BLIND_SELECT_BTN_PID 15 #define NEXT_ROUND_BTN_PID 16 @@ -114,6 +111,15 @@ #define REWARD_PANEL_BORDER_PID 19 #define SHOP_LIGHTS_4_PID 22 #define SHOP_BOTTOM_PANEL_BORDER_PID 26 + +#define PLAY_HAND_BTN_PID 6 +#define PLAY_HAND_BTN_BORDER_PID 7 +#define DISCARD_BTN_PID 13 +#define DISCARD_BTN_BORDER_PID 8 +#define SORT_BTNS_PID 9 +#define SORT_BY_RANK_BTN_BORDER_PID 22 +#define SORT_BY_SUIT_BTN_BORDER_PID 23 + // Naming the stage where cards return from the discard pile to the deck "undiscard" /* This needs to stay a power of 2 and small enough @@ -251,6 +257,9 @@ static void game_over_anim_frame(void); static void game_playing_discard_on_pressed(void); static void game_playing_play_hand_on_pressed(void); +static void game_playing_sort_by_rank_on_pressed(void); +static void game_playing_sort_by_suit_on_pressed(void); + static int game_playing_button_row_get_size(void); static bool game_playing_button_row_on_selection_changed( SelectionGrid* selection_grid, @@ -308,7 +317,8 @@ static void remove_owned_joker(int owned_joker_idx); static int hand_sel_idx_to_card_idx(int selection_index); static void hand_select_card(int index); -static void hand_change_sort(void); +static void hand_toggle_sort(void); +static void hand_change_sort(bool to_sort_by_suit); static void hand_deselect_all_cards(void); static bool can_play_hand(void); static bool can_discard_hand(void); @@ -468,8 +478,10 @@ SelectionGrid game_playing_selection_grid = { // Array of buttons by horizontal selection index (x) Button game_playing_buttons[] = { - {PLAY_HAND_BTN_BORDER_PID, PLAY_HAND_BTN_PID, game_playing_play_hand_on_pressed, can_play_hand }, - {DISCARD_BTN_BORDER_PID, DISCARD_BTN_PID, game_playing_discard_on_pressed, can_discard_hand}, + {PLAY_HAND_BTN_BORDER_PID, PLAY_HAND_BTN_PID, game_playing_play_hand_on_pressed, can_play_hand }, + {SORT_BY_RANK_BTN_BORDER_PID, SORT_BTNS_PID, game_playing_sort_by_rank_on_pressed, NULL }, + {SORT_BY_SUIT_BTN_BORDER_PID, SORT_BTNS_PID, game_playing_sort_by_suit_on_pressed, NULL }, + {DISCARD_BTN_BORDER_PID, DISCARD_BTN_PID, game_playing_discard_on_pressed, can_discard_hand}, }; SelectionGridRow shop_selection_rows[] = { @@ -2025,6 +2037,50 @@ static void game_playing_discard_on_pressed(void) selection_grid_move_selection_vert(&game_playing_selection_grid, -1); } +static void game_playing_sort_by_rank_on_pressed(void) +{ + hand_change_sort(false); +} + +static void game_playing_sort_by_suit_on_pressed(void) +{ + hand_change_sort(true); +} + +static void hand_deselect_all_cards(void) +{ + bool any_cards_deselected = false; + for (int i = 0; i <= get_hand_top(); i++) + { + if (card_object_is_selected(hand[i])) + { + card_object_set_selected(hand[i], false); + hand_selections--; + any_cards_deselected = true; + } + } + + if (any_cards_deselected) + { + play_sfx(SFX_CARD_DESELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME); + } +} + +static inline void hand_toggle_sort(void) +{ + sort_by_suit = !sort_by_suit; + sort_cards(); +} + +static inline void hand_change_sort(bool to_sort_by_suit) +{ + if (to_sort_by_suit != sort_by_suit) + { + sort_by_suit = to_sort_by_suit; + sort_cards(); + } +} + static void game_playing_play_hand_on_pressed(void) { if (!can_play_hand()) @@ -2161,7 +2217,7 @@ static void game_playing_hand_row_on_key_transit( } else if (key_hit(SORT_HAND)) { - hand_change_sort(); + hand_toggle_sort(); } } @@ -2208,31 +2264,6 @@ static void game_playing_button_row_on_key_hit(SelectionGrid* selection_grid, Se } } -static void hand_deselect_all_cards(void) -{ - bool any_cards_deselected = false; - for (int i = 0; i <= get_hand_top(); i++) - { - if (card_object_is_selected(hand[i])) - { - card_object_set_selected(hand[i], false); - hand_selections--; - any_cards_deselected = true; - } - } - - if (any_cards_deselected) - { - play_sfx(SFX_CARD_DESELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME); - } -} - -static void hand_change_sort(void) -{ - sort_by_suit = !sort_by_suit; - sort_cards(); -} - static bool can_play_hand(void) { if (hand_state != HAND_SELECT || hand_selections == 0)