21 stats_mode_strings = (
char**) malloc(
sizeof(
char*) * MAX_STATS_STRINGS);
22 RETURN_WHEN_NULL(stats_mode_strings, 1,
"Stats Mode",
"Failed to allocate memory for stats mode strings.")
24 for (
int i = 0; i < MAX_STATS_STRINGS; i++) {
25 stats_mode_strings[i] = NULL;
30 RETURN_WHEN_NULL(stats_menu_options, -1,
"Stats Mode",
31 "Allocated memory for stats window options in memory pool is NULL");
48 char stats_info[MAX_STRING_LENGTH];
54 snprintf(stats_info,
sizeof(stats_info),
"%s: %4d / %-4d| %s: %4d / %-4d | %s: %4d / %-4d",
55 stats_mode_strings[HEALTH_STR], player->current_resources.health, player->max_resources.health,
56 stats_mode_strings[MANA_STR], player->current_resources.mana, player->max_resources.mana,
57 stats_mode_strings[STAMINA_STR], player->current_resources.stamina, player->max_resources.stamina);
61 snprintf(stats_info,
sizeof(stats_info),
"%s: %-4d | %s: %-4d | %s: %-4d | %s: %-4d",
62 stats_mode_strings[STRENGTH_STR], player->base_stats.strength,
63 stats_mode_strings[INTELLIGENCE_STR], player->base_stats.intelligence,
64 stats_mode_strings[DEXTERITY_STR], player->base_stats.dexterity,
65 stats_mode_strings[CONSTITUTION_STR], player->base_stats.constitution);
69 snprintf(stats_info,
sizeof(stats_info),
"%s: %-4d | %s: %4d / %-4d",
70 stats_mode_strings[LEVEL_STR], player->level,
75 snprintf(stats_info,
sizeof(stats_info),
"%s:", stats_mode_strings[INVENTORY_MENU_TITLE]);
79 for (
int i = 0; i < MAX_SLOT; i++) {
80 if (player->equipment[i] != NULL) {
81 snprintf(stats_info,
sizeof(stats_info),
"%s: %s | %s: %-4d, %s: %-4d",
82 stats_mode_strings[EQUIPPED_ARMOR_STR], player->equipment[i]->local_key,
83 stats_mode_strings[ARMOR_STR], player->equipment[i]->defenses.armor,
84 stats_mode_strings[MAGIC_RESISTANCE_STR], player->equipment[i]->defenses.magic_resist);
86 snprintf(stats_info,
sizeof(stats_info),
"%s %d", stats_mode_strings[EMPTY_ARMOR_SLOT_STR], i);
94 snprintf(stats_info,
sizeof(stats_info),
"%s: %d", stats_mode_strings[AVAILABLE_SKILL_POINTS_STR], player->skill_points);
98void draw_stats_menu(
const char* title,
const char** options,
int option_count,
int selected_index,
const char* footer) {
104 print_menu(title, options, option_count, selected_index, y, x,
105 DEFAULT_COLORS, DEFAULT_COLORS, INVERTED_COLORS);
108 y += option_count + 1;
121 if (stats_mode_strings != NULL) {
122 for (
int i = 0; i < MAX_STATS_STRINGS; i++) {
123 if (stats_mode_strings[i] != NULL) {
124 free(stats_mode_strings[i]);
127 free(stats_mode_strings);
Exposes functions for working working with the character.
memory_pool_t * main_memory_pool
Global memory pool for the application.
Exposes functions for the IO-Handler.
int calculate_xp_for_next_level(int level)
Calculates the XP required for the next level.
Exposes functions for working with the character.
void observe_local(void(*update_func)(void))
Registers an observer function to be notified of updates from the local handler.
Exposes public functions for the localization handler.
Header file for logging functionality of the game.
void * memory_pool_alloc(memory_pool_t *pool, size_t size)
Allocates memory on the given memory pool.
Exposes functions for working with the memory management.
void print_text_default(int y, int x, const char *text)
Print text at a specific position with default colors.
bool render_frame(void)
Render the current frame.
void print_menu(const char *title, const char **options, int option_count, int selected_index, int y, int x, uint64_t title_channel, uint64_t option_channel, uint64_t selected_channel)
Print a menu with selection highlighting.
void clear_screen(void)
Clear the screen.
Exposes functions for outputting to the console.
Exposes functions and enums for working with localization in the map mode.
void draw_stats_log(const char *message)
Display a message in the stats log.
void shutdown_stats_mode()
Shutdown the stats mode.
void draw_stats_menu(const char *title, const char **options, int option_count, int selected_index, const char *footer)
Draw the stats menu.
int init_stats_mode()
Initialize the stats mode.
void render_stats_window(const character_t *player)
Render the stats window.
Exposes functions for outputing to the screen in stats mode.
void update_stats_local(void)
Update localized strings for the stats mode.
String struct with a fixed maximum length, it is directly linked to the macro MAX_STRING_LENGTH.