OpenTTD Source 20241224-master-gf74b0cf984
console_func.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef CONSOLE_FUNC_H
11#define CONSOLE_FUNC_H
12
13#include "console_type.h"
14#include "core/format.hpp"
15
16/* console modes */
17extern IConsoleModes _iconsole_mode;
18
19/* console functions */
20void IConsoleInit();
21void IConsoleFree();
22void IConsoleClose();
23
24/* console output */
25void IConsolePrint(TextColour colour_code, const std::string &string);
26
40template <typename A, typename ... Args>
41inline void IConsolePrint(TextColour colour_code, fmt::format_string<A, Args...> format, A&& first_arg, Args&&... other_args)
42{
43 /* The separate first_arg argument is added to aid overloading.
44 * Otherwise the calls that do no need formatting will still use this function. */
45 IConsolePrint(colour_code, fmt::format(format, std::forward<A>(first_arg), std::forward<Args>(other_args)...));
46}
47
48/* Parser */
49void IConsoleCmdExec(const std::string &command_string, const uint recurse_count = 0);
50
52
53#endif /* CONSOLE_FUNC_H */
void IConsoleCmdExec(const std::string &command_string, const uint recurse_count=0)
Execute a given command passed to us.
Definition console.cpp:291
void IConsoleClose()
Close the in-game console.
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
void IConsolePrint(TextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.
Definition console.cpp:89
Globally used console related types.
IConsoleModes
Modes of the in-game console.
String formatting functions and helpers.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:260