libtcod
Loading...
Searching...
No Matches
console_etc.h
Go to the documentation of this file.
1/* BSD 3-Clause License
2 *
3 * Copyright © 2008-2025, Jice and the libtcod contributors.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34#pragma once
35#ifndef TCOD_CONSOLE_ETC_H_
36#define TCOD_CONSOLE_ETC_H_
37
38#include <stdbool.h>
39#ifndef NO_UNICODE
40#include <wchar.h>
41#endif
42
43#include "color.h"
44#include "config.h"
45#include "console.h"
46#include "console_types.h"
47#include "context.h"
48#include "error.h"
49#include "image.h"
50#include "list.h"
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56#define TCOD_BKGND_ALPHA(alpha) ((TCOD_bkgnd_flag_t)(TCOD_BKGND_ALPH | (((uint8_t)(alpha * 255)) << 8)))
57#define TCOD_BKGND_ADDALPHA(alpha) ((TCOD_bkgnd_flag_t)(TCOD_BKGND_ADDA | (((uint8_t)(alpha * 255)) << 8)))
58
59TCOD_DEPRECATED(
60 "This function is not compatible with contexts. Consider using tcod::load_tilesheet or TCOD_tileset_load instead."
61 " https://libtcod.readthedocs.io/en/latest/upgrading.html")
62TCODLIB_API TCOD_Error
63TCOD_console_set_custom_font(const char* fontFile, int flags, int nb_char_horiz, int nb_char_vertic);
64TCOD_DEPRECATED("This function is not compatible with contexts.")
65TCODLIB_API void TCOD_console_map_ascii_code_to_font(int asciiCode, int fontCharX, int fontCharY);
66TCOD_DEPRECATED("This function is not compatible with contexts.")
67TCODLIB_API void TCOD_console_map_ascii_codes_to_font(int asciiCode, int nbCodes, int fontCharX, int fontCharY);
68TCOD_DEPRECATED("This function is not compatible with contexts.")
69TCODLIB_API void TCOD_console_map_string_to_font(const char* s, int fontCharX, int fontCharY);
70#ifndef NO_UNICODE
71TCOD_DEPRECATED("This function is not compatible with contexts.")
72TCODLIB_API void TCOD_console_map_string_to_font_utf(const wchar_t* s, int fontCharX, int fontCharY);
73#endif
74
75TCOD_DEPRECATED("This function does nothing.")
76TCODLIB_API void TCOD_console_set_dirty(int x, int y, int w, int h);
89TCOD_PUBLIC TCOD_Error TCOD_console_flush_ex(TCOD_Console* console, struct TCOD_ViewportOptions* viewport);
102TCOD_DEPRECATED("Use SDL to check the keyboard state.")
104
105/* ASCII paint file support */
106TCODLIB_API TCOD_console_t TCOD_console_from_file(const char* filename);
107TCODLIB_API bool TCOD_console_load_asc(TCOD_console_t con, const char* filename);
108TCODLIB_API bool TCOD_console_load_apf(TCOD_console_t con, const char* filename);
109TCODLIB_API bool TCOD_console_save_asc(TCOD_console_t con, const char* filename);
110TCODLIB_API bool TCOD_console_save_apf(TCOD_console_t con, const char* filename);
111
112#ifndef NO_SDL
113TCODLIB_BEGIN_IGNORE_DEPRECATIONS
121TCOD_DEPRECATED("This API is deprecated, use SDL_PollEvent instead.")
132TCOD_DEPRECATED("This API is deprecated, use SDL_WaitEvent instead.")
134
135TCOD_DEPRECATED("This function does not support contexts. Consider using `TCOD_console_credits_render_ex`.")
136TCODLIB_API void TCOD_console_credits(void);
137TCOD_DEPRECATED("This function does not support contexts.")
138TCODLIB_API void TCOD_console_credits_reset(void);
139TCOD_DEPRECATED("This function does not support contexts. Consider using `TCOD_console_credits_render_ex`.")
140TCODLIB_API bool TCOD_console_credits_render(int x, int y, bool alpha);
141TCODLIB_END_IGNORE_DEPRECATIONS
142
156TCODLIB_API bool TCOD_console_credits_render_ex(TCOD_Console* console, int x, int y, bool alpha, float delta_time);
157
158TCOD_DEPRECATED("This function is a stub and will do nothing.")
159TCODLIB_API void TCOD_console_set_keyboard_repeat(int initial_delay, int interval);
160TCOD_DEPRECATED("This function is a stub and will do nothing.")
161TCODLIB_API void TCOD_console_disable_keyboard_repeat(void);
162#endif // NO_SDL
174TCOD_DEPRECATED("This function does not support contexts.")
175TCOD_PUBLIC
176void TCOD_console_set_fade(uint8_t val, TCOD_color_t fade_color);
182TCOD_PUBLIC TCOD_NODISCARD uint8_t TCOD_console_get_fade(void);
188TCOD_PUBLIC TCOD_NODISCARD TCOD_color_t TCOD_console_get_fading_color(void);
189#ifdef __cplusplus
190} // extern "C"
191#endif
192#endif // TCOD_CONSOLE_ETC_H_
Color handling module.
Libtcod config header.
Various console functions.
TCOD_Error TCOD_console_flush(void)
Render and present the root console to the active display.
TCODLIB_END_IGNORE_DEPRECATIONS bool TCOD_console_credits_render_ex(TCOD_Console *console, int x, int y, bool alpha, float delta_time)
Render a libtcod credit animation to a console.
TCODLIB_BEGIN_IGNORE_DEPRECATIONS TCOD_key_t TCOD_console_check_for_keypress(int flags)
Return immediately with a recently pressed key.
bool TCOD_console_is_key_pressed(TCOD_keycode_t key)
Return True if the libtcod keycode is held.
uint8_t TCOD_console_get_fade(void)
Return the fade value.
void TCOD_console_set_fade(uint8_t val, TCOD_color_t fade_color)
Fade the color of the display.
TCOD_key_t TCOD_console_wait_for_keypress(bool flush)
Wait for a key press event, then return it.
TCOD_color_t TCOD_console_get_fading_color(void)
Return the fade color.
TCOD_Error TCOD_console_flush_ex(TCOD_Console *console, struct TCOD_ViewportOptions *viewport)
Render and present a console with optional viewport options.
C types for console functions.
TCOD_keycode_t
Libtcod specific codes representing keys on the keyboard.
Definition console_types.h:126
Libtcod display management context.
Error handling module.
TCOD_Error
An enum of libtcod error codes.
Definition error.h:48
Image handling module.
Deprecated libtcod list module.
A libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console.h:125
Viewport options for the rendering context.
Definition context_viewport.h:48
Libtcod key event data, as a keycode or text character.
Definition console_types.h:207