OpenTTD Source 20241224-master-gf74b0cf984
console_func.h File Reference

Console functions used outside of the console code. More...

#include "console_type.h"
#include "core/format.hpp"

Go to the source code of this file.

Functions

void IConsoleInit ()
 
void IConsoleFree ()
 
void IConsoleClose ()
 Close the in-game console.
 
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.
 
template<typename A , typename ... Args>
void IConsolePrint (TextColour colour_code, fmt::format_string< A, Args... > format, A &&first_arg, Args &&... other_args)
 Handle the printing of text entered into the console or redirected there by any other means.
 
void IConsoleCmdExec (const std::string &command_string, const uint recurse_count=0)
 Execute a given command passed to us.
 
bool IsValidConsoleColour (TextColour c)
 Check whether the given TextColour is valid for console usage.
 

Variables

IConsoleModes _iconsole_mode
 

Detailed Description

Console functions used outside of the console code.

Definition in file console_func.h.

Function Documentation

◆ IConsoleClose()

void IConsoleClose ( )

Close the in-game console.

Definition at line 445 of file console_gui.cpp.

References ICONSOLE_OPENED, and IConsoleSwitch().

Referenced by InitWindowSystem().

◆ IConsoleCmdExec()

void IConsoleCmdExec ( const std::string &  command_string,
const uint  recurse_count 
)

◆ IConsoleFree()

void IConsoleFree ( )

Definition at line 74 of file console.cpp.

◆ IConsoleInit()

void IConsoleInit ( )

Definition at line 39 of file console.cpp.

◆ IConsolePrint() [1/2]

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.

Text can be redirected to other clients in a network game as well as to a logfile. If the network server is a dedicated server, all activities are also logged. All lines to print are added to a temporary buffer which can be used as a history to print them onscreen

Parameters
colour_codeThe colour of the command.
stringThe message to output on the console (notice, error, etc.)

Definition at line 89 of file console.cpp.

References _network_dedicated, _redirect_console_to_admin, _redirect_console_to_client, GetLogPrefix(), IConsoleGUIPrint(), INVALID_ADMIN_ID, INVALID_CLIENT_ID, IsValidConsoleColour(), NetworkAdminConsole(), NetworkServerSendAdminRcon(), NetworkServerSendRcon(), StrMakeValid(), and SVS_NONE.

Referenced by IConsole::AliasRegister(), ConPrintFramerate(), DebugSendRemoteMessages(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_CMD(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), IConsoleAliasExec(), IConsoleCmdExec(), IConsoleGetSetting(), IConsoleListSettings(), IConsolePrint(), NetworkAutoCleanCompanies(), NetworkAvailable(), NetworkPrintClients(), NetworkServer_Tick(), NetworkServerShowStatusToConsole(), ConsoleContentCallback::OnConnect(), ConsoleContentCallback::OnDisconnect(), ConsoleContentCallback::OnDownloadComplete(), IConsoleWindow::OnKeyPress(), OutputContentState(), Gamelog::PrintConsole(), PrintLineByLine(), ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND(), ClientNetworkGameSocketHandler::Receive_SERVER_RCON(), and ShowErrorMessage().

◆ IConsolePrint() [2/2]

template<typename A , typename ... Args>
void IConsolePrint ( TextColour  colour_code,
fmt::format_string< A, Args... >  format,
A &&  first_arg,
Args &&...  other_args 
)
inline

Handle the printing of text entered into the console or redirected there by any other means.

Text can be redirected to other clients in a network game as well as to a logfile. If the network server is a dedicated server, all activities are also logged. All lines to print are added to a temporary buffer which can be used as a history to print them onscreen

Parameters
colour_codeThe colour of the command.
format_stringThe formatting string to tell what to do with the remaining arguments.
first_argThe first argument to the format.
other_argsThe other arguments to the format.
Template Parameters
AThe type of the first argument.
ArgsThe types of the other arguments.

Definition at line 41 of file console_func.h.

References IConsolePrint().

◆ IsValidConsoleColour()

bool IsValidConsoleColour ( TextColour  c)

Check whether the given TextColour is valid for console usage.

Parameters
cThe text colour to compare to.
Returns
true iff the TextColour is valid for console usage.

Definition at line 541 of file console_gui.cpp.

References GetColourGradient(), and TC_IS_PALETTE_COLOUR.

Referenced by IConsolePrint(), ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(), ClientNetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT(), and ClientNetworkGameSocketHandler::Receive_SERVER_RCON().

Variable Documentation

◆ _iconsole_mode

IConsoleModes _iconsole_mode
extern

Definition at line 113 of file console_gui.cpp.