OpenTTD Source  20241121-master-g67a0fccfad
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 */
17 extern IConsoleModes _iconsole_mode;
18 
19 /* console functions */
20 void IConsoleInit();
21 void IConsoleFree();
22 void IConsoleClose();
23 
24 /* console output */
25 void IConsolePrint(TextColour colour_code, const std::string &string);
26 
40 template <typename A, typename ... Args>
41 inline 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 */
49 void 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.
Definition: console_type.h:16
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