Mercurial > molko
comparison libmlk-ui/ui/debug.h @ 243:71b3b7036de7
misc: lot of cleanups,
- prefix libraries with libmlk,
- move assets from source directories closes #2520,
- prefix header guards closes #2519
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 28 Nov 2020 22:37:30 +0100 |
parents | libui/ui/debug.h@dd7c8d4321a3 |
children | 08ab73b32832 |
comparison
equal
deleted
inserted
replaced
242:4c24604efcab | 243:71b3b7036de7 |
---|---|
1 /* | |
2 * debug.h -- debugging interfaces | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef MOLKO_UI_DEBUG_H | |
20 #define MOLKO_UI_DEBUG_H | |
21 | |
22 /** | |
23 * \file debug.h | |
24 * \brief Debugging interfaces. | |
25 * | |
26 * This module provides functions to draw debugging information within the game | |
27 * window. It is mostly used for information only when state of the game is | |
28 * better inspected via direct window information rather than writing in the | |
29 * console. | |
30 * | |
31 * Predefined core states may print debugging information if | |
32 * debug_options.enabled variable is set to true. However, you need to specify | |
33 * the font to use in order to work. | |
34 * | |
35 * Each call to \ref debugf or \ref vdebugf automatically adjust | |
36 * next coordinate for rendering the text. As such, user may simply print | |
37 * several lines of text without having to deal with that manually. | |
38 */ | |
39 | |
40 #include <stdbool.h> | |
41 #include <stdarg.h> | |
42 | |
43 #include <core/font.h> | |
44 | |
45 /** | |
46 * Maximum content length per report. | |
47 */ | |
48 #define DEBUG_LINE_MAX 1024 | |
49 | |
50 struct theme; | |
51 | |
52 /** | |
53 * \brief Debugging options. | |
54 * | |
55 * Fill this structure with appropriate values to change debugging behavior | |
56 * in core API. | |
57 */ | |
58 struct debug_options { | |
59 bool enable; /*!< (+) Enable core API debugging. */ | |
60 }; | |
61 | |
62 /** | |
63 * \brief Debug context. | |
64 * | |
65 * Use this structure each time you need to print one or more messages. | |
66 */ | |
67 struct debug_report { | |
68 const struct theme *theme; /*!< (+&?) Theme to use. */ | |
69 unsigned int count; /*!< (-) Number of messages already printed. */ | |
70 }; | |
71 | |
72 /** | |
73 * Global debugging options. | |
74 */ | |
75 extern struct debug_options debug_options; | |
76 | |
77 /** | |
78 * Print debugging information into the screen. | |
79 * | |
80 * \pre report != NULL | |
81 * \pre fmt != NULL | |
82 * \param report the reporting context | |
83 * \param fmt the printf(3) format string | |
84 * \note The message length must not exceed DEBUG_LINE_MAX, otherwise its | |
85 * result is truncated. | |
86 */ | |
87 void | |
88 debugf(struct debug_report *report, const char *fmt, ...); | |
89 | |
90 /** | |
91 * Similar to \ref debugf with a va_list arguments pointer. | |
92 * | |
93 * \pre fmt != NULL | |
94 * \param report the reporting context | |
95 * \param fmt the printf(3) format string | |
96 * \param ap the argument list | |
97 */ | |
98 void | |
99 vdebugf(struct debug_report *report, const char *fmt, va_list ap); | |
100 | |
101 #endif /* !MOLKO_UI_DEBUG_H */ |