Add console input

This commit is contained in:
quaK 2022-05-18 14:35:39 +03:00
parent d5073559b7
commit b9e9369637
7 changed files with 33 additions and 12 deletions

View File

@ -103,7 +103,7 @@ namespace binding
if (static_cast<size_t>(key) < custom_binds.size() && !custom_binds[key].empty())
{
game::Cbuf_AddText(local_client_num, utils::string::va("%s\n", custom_binds[key].data()));
game::Cbuf_AddText(local_client_num, 0, utils::string::va("%s\n", custom_binds[key].data()));
}
return;

View File

@ -493,7 +493,7 @@ namespace command
}
else
{
game::Cbuf_AddText(0, command.data());
game::Cbuf_AddText(0, 0, command.data());
}
}

View File

@ -14,6 +14,8 @@ namespace console
{
namespace
{
static bool ingame = false;
DWORD WINAPI console(LPVOID)
{
ShowWindow(GetConsoleWindow(), SW_SHOW);
@ -24,6 +26,10 @@ namespace console
while (true)
{
std::getline(std::cin, cmd);
if (ingame)
{
game::Cbuf_AddText(0, 0, cmd.data());
}
}
return 0;
@ -45,10 +51,6 @@ namespace console
printf("%s\n", message.data());
//game_console::print(type, message);
//messages.access([&message](message_queue& msgs)
// {
// msgs.emplace(message);
// });
}
void print(const int type, const char* fmt, ...)
@ -68,6 +70,16 @@ namespace console
{
CreateThread(0, 0, console, 0, 0, 0);
}
void post_unpack() override
{
ingame = true;
}
void pre_destroy() override
{
ingame = false;
}
};
}

View File

@ -9,6 +9,7 @@ namespace console
enum console_type
{
con_type_error = 1,
con_type_dev = 2,
con_type_warning = 3,
con_type_info = 7
};
@ -21,6 +22,14 @@ namespace console
print(con_type_error, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void debug(const char* fmt, Args&&... args)
{
#ifdef DEBUG
print(2, fmt, std::forward<Args>(args)...);
#endif
}
template <typename... Args>
void warn(const char* fmt, Args&&... args)
{

View File

@ -83,8 +83,8 @@ namespace dedicated
{
if (game::Live_SyncOnlineDataFlags(0) == 0)
{
game::Cbuf_AddText(client, command);
game::Cbuf_AddText(client, "\n");
game::Cbuf_AddText(client, 0, command);
game::Cbuf_AddText(client, 0, "\n");
}
else
{
@ -99,8 +99,8 @@ namespace dedicated
for (const auto& command : queue)
{
game::Cbuf_AddText(0, command.data());
game::Cbuf_AddText(0, "\n");
game::Cbuf_AddText(0, 0, command.data());
game::Cbuf_AddText(0, 0, "\n");
}
}

View File

@ -680,7 +680,7 @@ namespace game_console
if (key == game::keyNum_t::K_ENTER)
{
game::Cbuf_AddText(0, utils::string::va("%s \n", fixed_input.data()));
game::Cbuf_AddText(0, 0, utils::string::va("%s \n", fixed_input.data()));
if (history_index != -1)
{

View File

@ -15,7 +15,7 @@ namespace game
WEAK symbol<unsigned int(unsigned int id)> AllocThread{0x0, 0x509440};
WEAK symbol<ObjectVariableValue*(unsigned int* id)> AllocVariable{0x0, 0x0};
WEAK symbol<void(int localClientNum, const char* text)> Cbuf_AddText{0x0, 0x1CF480};
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cbuf_AddText{0x0, 0x1CF480};
WEAK symbol<void(int localClientNum, int controllerIndex, const char* buffer,
void (int, int, const char*))> Cbuf_ExecuteBufferInternal{0x0, 0x155BC0};
WEAK symbol<void(const char* message)> Conbuf_AppendText{0x0, 0x0};