root / proj / src / project / include / scoreboards.h
History | View | Annotate | Download (2.42 KB)
1 |
#ifndef SCOREBOARD_H_INCLUDED
|
---|---|
2 |
#define SCOREBOARD_H_INCLUDED
|
3 |
|
4 |
/**
|
5 |
* @defgroup scoreboards scoreboards
|
6 |
* @ingroup proj
|
7 |
* @brief Scoreboards module.
|
8 |
*
|
9 |
* @{
|
10 |
*/
|
11 |
|
12 |
#include "libs.h" |
13 |
#include <stdint.h> |
14 |
|
15 |
/**
|
16 |
* @brief Score.
|
17 |
*/
|
18 |
typedef struct score_info score_info_t; |
19 |
|
20 |
/**
|
21 |
* @brief Table of highscores.
|
22 |
*/
|
23 |
typedef struct highscores highscores_t; |
24 |
/**
|
25 |
* @brief Construct score.
|
26 |
* @param score Game score.
|
27 |
* @param time_played Time elapsed on game.
|
28 |
* @return Pointer to constructed score, or NULL if failed.
|
29 |
*/
|
30 |
score_info_t* (score_ctor)(int score, int time_played); |
31 |
|
32 |
/**
|
33 |
* @brief Destruct score.
|
34 |
* @param p Pointer to score to destruct
|
35 |
*/
|
36 |
void (score_dtor)(score_info_t *p);
|
37 |
|
38 |
/**
|
39 |
* @brief Construct highscores.
|
40 |
* @param fnt Font to use when rendering highscores text
|
41 |
* @param path Path to file to be read with highscores values.
|
42 |
* @return Pointer to constructed highscores, or NULL if failed.
|
43 |
*/
|
44 |
highscores_t* (highscores_ctor)(const font_t *fnt, const char *path); |
45 |
/**
|
46 |
* @brief Save highscore into file.
|
47 |
* @param p Pointer to highscores
|
48 |
* @param path Path to file to be written
|
49 |
*/
|
50 |
void (highscores_save)(const highscores_t *p, const char *path); |
51 |
|
52 |
/**
|
53 |
* @brief Checks if score is higher than any of the top 3, and if so replaces the highscores.
|
54 |
* @param p Pointer to highscores.
|
55 |
* @param score New score obtained.
|
56 |
* @param time_played Time played
|
57 |
*/
|
58 |
void (check_new_score)(highscores_t *p, int score, int time_played); |
59 |
/**
|
60 |
* @brief Updates highscores text.
|
61 |
* @param p Pointer to highscores.
|
62 |
*/
|
63 |
void (highscores_update_text)(highscores_t *p);
|
64 |
/**
|
65 |
* @brief highscore menu state.
|
66 |
*
|
67 |
* This function allows to check if the mouse is hovering over the back button, and knowing
|
68 |
* if it was clicked.
|
69 |
* @param menu Pointer to highscore
|
70 |
* @param click 0 if mouse right button is clicked, other value otherwise
|
71 |
* @return return 0 if back option is clicked else -1
|
72 |
*/
|
73 |
int (highscore_update_state)(highscores_t *p, int click); |
74 |
/**
|
75 |
* @brief Draw highscore on screen buffer.
|
76 |
* @param p Pointer to highscores to be drawn
|
77 |
*/
|
78 |
void (highscores_draw)(highscores_t *p);
|
79 |
/**
|
80 |
* @brief Destruct menu.
|
81 |
* @param p Pointer to menu to destruct
|
82 |
*/
|
83 |
void (highscores_dtor)(highscores_t *p);
|
84 |
|
85 |
/**
|
86 |
* @}
|
87 |
*/
|
88 |
|
89 |
|
90 |
#endif /* end of include guard: SCOREBOARD_H_INCLUDED */ |