h2-mod/src/client/component/console.cpp

42 lines
726 B
C++
Raw Normal View History

2021-09-06 18:40:37 -04:00
#include <std_include.hpp>
#include "loader/component_loader.hpp"
2021-09-07 19:21:20 -04:00
#include "command.hpp"
2021-09-06 18:40:37 -04:00
#include "game_console.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
2021-09-07 19:21:20 -04:00
#include <utils/thread.hpp>
2021-09-06 18:40:37 -04:00
#include <utils/hook.hpp>
namespace console
{
namespace
{
2021-09-07 19:21:20 -04:00
std::thread console_thread;
2021-09-06 18:40:37 -04:00
}
class component final : public component_interface
{
public:
void post_unpack() override
{
2021-09-07 19:21:20 -04:00
ShowWindow(GetConsoleWindow(), SW_SHOW);
SetConsoleTitle("H2-Mod");
console_thread = utils::thread::create_named_thread("Console", []()
{
std::string cmd;
while (true)
{
std::getline(std::cin, cmd);
command::execute(cmd.data(), false);
}
});
2021-09-06 18:40:37 -04:00
}
};
}
REGISTER_COMPONENT(console::component)