Refactor/main menu (#416)
* Add basic common_ui background gfx functions * Move game main menu to separate file * clang format * tmp commit basic docs * clang format * scope vars and cleanup * Quick consistency update. Finalize. This branch is based on: https://github.com/GBALATRO/balatro-gba/pull/363 Co-authored-by: emiyl <me@emiyl.com> * Simplify global struct * clang-format * Add clang-format to subdirs * Move timer definitions into their own file * clang-format * Fix action yml * docs * Update for PR * Move game start to a state * Remove lag switch * Remove GameVariables pointer for callbacks * Make game_vars a global * move declaration of game vars in header * Fix multiple game_vars * fix for pr * remove change_background in update again * clang format * Make bgCallbacks table static const --------- Co-authored-by: emiyl <me@emiyl.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// clang-format off
|
||||
// (stateEnum, on_init, on_update, on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_SPLASH_SCREEN, splash_screen_on_init, splash_screen_on_update, splash_screen_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_MAIN_MENU, game_main_menu_on_init, game_main_menu_on_update, noop)
|
||||
DEF_STATE_INFO(GAME_STATE_MAIN_MENU, game_main_menu_on_init, game_main_menu_on_update, game_main_menu_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_GAME_START, noop, game_start, noop)
|
||||
DEF_STATE_INFO(GAME_STATE_PLAYING, game_round_on_init, game_playing_on_update, noop)
|
||||
DEF_STATE_INFO(GAME_STATE_ROUND_END, noop, game_round_end_on_update, game_round_end_on_exit)
|
||||
DEF_STATE_INFO(GAME_STATE_SHOP, noop, game_shop_on_update, game_shop_on_exit)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
extern GameVariables g_game_vars;
|
||||
|
||||
#define MAX_HAND_SIZE 16
|
||||
#define MAX_DECK_SIZE 52
|
||||
#define MAX_JOKERS_HELD_SIZE 5 // This doesn't account for negatives right now.
|
||||
@@ -172,6 +174,8 @@ void set_game_speed(int new_game_speed);
|
||||
bool is_shortcut_joker_active(void);
|
||||
int get_straight_and_flush_size(void);
|
||||
|
||||
void game_start(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.
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file main_menu.h
|
||||
*
|
||||
* @brief Main menu state functions
|
||||
*/
|
||||
#ifndef GAME_MAIN_MENU_H
|
||||
#define GAME_MAIN_MENU_H
|
||||
|
||||
#include "game_variables.h"
|
||||
|
||||
/**
|
||||
* @brief Change the main menu background
|
||||
*/
|
||||
void game_main_menu_change_background(void);
|
||||
|
||||
/**
|
||||
* @brief Main menu state initialization
|
||||
*
|
||||
* @param vars passed @ref GameVariables struct
|
||||
*/
|
||||
void game_main_menu_on_init(void);
|
||||
|
||||
/**
|
||||
* @brief Main menu state update
|
||||
*
|
||||
* @param vars passed @ref GameVariables struct
|
||||
*/
|
||||
void game_main_menu_on_update(void);
|
||||
|
||||
/**
|
||||
* @brief Main menu cleanup (called when transitioning to game start)
|
||||
*
|
||||
* @param vars passed @ref GameVariables struct
|
||||
*/
|
||||
void game_main_menu_on_exit(void);
|
||||
|
||||
#endif // GAME_MAIN_MENU_H
|
||||
@@ -6,6 +6,8 @@
|
||||
#ifndef GAME_VARIABLES_H
|
||||
#define GAME_VARIABLES_H
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
/**
|
||||
* @brief A central location for all game variables.
|
||||
*
|
||||
@@ -14,7 +16,8 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
s32 timer;
|
||||
u32 rng_seed;
|
||||
} GameVariables;
|
||||
|
||||
extern GameVariables g_game_vars;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file timer.h
|
||||
*
|
||||
* @brief Timer constants
|
||||
*
|
||||
*/
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#define TM_ZERO 0
|
||||
|
||||
#endif // TIMER_H
|
||||
Reference in New Issue
Block a user