Add basic common_ui background gfx functions (#415)

* Add basic common_ui background gfx functions

* clang format

* document common_ui.h

* Remove unused tonc header

* Fix header guard name convention

* more header cleanup

* claaaaanggggg format
This commit is contained in:
Rickey
2026-03-31 21:04:47 -07:00
committed by GitHub
parent 91bc9b949e
commit f46395b9d0
5 changed files with 62 additions and 15 deletions
+2 -2
View File
@@ -27,8 +27,8 @@ LIBTONC := $(DEVKITPRO)/libtonc
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
INCLUDES := include
SOURCES := source source/game
INCLUDES := include include/game
DATA :=
MUSIC := audio
GRAPHICS := graphics
+6 -11
View File
@@ -1,6 +1,7 @@
#ifndef GAME_H
#define GAME_H
#include "game/common_ui.h"
#include "game_variables.h"
#include <tonc.h>
@@ -38,17 +39,6 @@ typedef struct CardObject CardObject;
typedef struct Card Card;
typedef struct JokerObject JokerObject;
enum BackgroundId
{
BG_NONE,
BG_CARD_SELECTING,
BG_CARD_PLAYING,
BG_ROUND_END,
BG_SHOP,
BG_BLIND_SELECT,
BG_MAIN_MENU
};
// Enum value names in ../include/def_state_info_table.h
enum GameState
{
@@ -182,4 +172,9 @@ void set_game_speed(int new_game_speed);
bool is_shortcut_joker_active(void);
int get_straight_and_flush_size(void);
// Temporary change for Refactor. Currently this compatibility binder is to allow
// simultaneous integration of the new system in `common_ui` with the the existing
// old system incrementally and without losing functionality.
void change_background_legacy(enum BackgroundId id);
#endif // GAME_H
+30
View File
@@ -0,0 +1,30 @@
/**
* @file common_ui.h
*
* @brief Common functions to render UI elements.
*/
#ifndef COMMON_UI_H
#define COMMON_UI_H
/**
* @brief Enum of possible backgrounds to render with @ref change_background
*/
enum BackgroundId
{
BG_NONE,
BG_CARD_SELECTING,
BG_CARD_PLAYING,
BG_ROUND_END,
BG_SHOP,
BG_BLIND_SELECT,
BG_MAIN_MENU
};
/**
* Change the background
*
* @param id @ref BackgroundId to render to screen
*/
void change_background(enum BackgroundId id);
#endif // COMMON_UI_H
+2 -2
View File
@@ -11,6 +11,7 @@
#include "blind.h"
#include "button.h"
#include "card.h"
#include "game/common_ui.h"
#include "graphic_utils.h"
#include "hand_analysis.h"
#include "joker.h"
@@ -235,7 +236,6 @@ static void game_round_end_display_cashout(void);
static void game_round_end_dismiss_round_end_panel(void);
static void sort_cards(void);
static void change_background(enum BackgroundId id);
static void display_temp_score(u32 value);
static void display_score(u32 value);
static void check_flaming_score(void);
@@ -1424,7 +1424,7 @@ static inline void reset_top_left_panel_bottom_row()
main_bg_se_copy_rect(TOP_LEFT_PANEL_BOTTOM_ROW_RESET_RECT, top_left_panel_bottom_row_pos);
}
static void change_background(enum BackgroundId id)
void change_background_legacy(enum BackgroundId id)
{
if (background == id)
{
+22
View File
@@ -0,0 +1,22 @@
#include "game/common_ui.h"
#include "game.h"
typedef void (*BackgroundRenderCallback)(void);
// Map to fill in for refactor
BackgroundRenderCallback bgCallbacks[] =
{
[BG_NONE] = NULL,
[BG_CARD_SELECTING] = NULL,
[BG_CARD_PLAYING] = NULL,
[BG_ROUND_END] = NULL,
[BG_SHOP] = NULL,
[BG_BLIND_SELECT] = NULL,
[BG_MAIN_MENU] = NULL,
};
void change_background(enum BackgroundId id)
{
change_background_legacy(id);
}