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/>.
8 /** @file console_func.h Console functions used outside of the console code. */
10 #ifndef CONSOLE_FUNC_H
11 #define CONSOLE_FUNC_H
13 #include "console_type.h"
14 #include "core/format.hpp"
17 extern IConsoleModes _iconsole_mode
;
19 /* console functions */
25 void IConsolePrint(TextColour colour_code
, const std::string
&string
);
28 * Handle the printing of text entered into the console or redirected there
29 * by any other means. Text can be redirected to other clients in a network game
30 * as well as to a logfile. If the network server is a dedicated server, all activities
31 * are also logged. All lines to print are added to a temporary buffer which can be
32 * used as a history to print them onscreen
33 * @param colour_code The colour of the command.
34 * @param format_string The formatting string to tell what to do with the remaining arguments.
35 * @param first_arg The first argument to the format.
36 * @param other_args The other arguments to the format.
37 * @tparam A The type of the first argument.
38 * @tparam Args The types of the other arguments.
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
)
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
)...));
49 void IConsoleCmdExec(const std::string
&command_string
, const uint recurse_count
= 0);
51 bool IsValidConsoleColour(TextColour c
);
53 #endif /* CONSOLE_FUNC_H */