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

42 lines
727 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);
2021-12-20 20:00:22 -05:00
game_console::add(cmd.data(), false);
2021-09-07 19:21:20 -04:00
}
});
2021-09-06 18:40:37 -04:00
}
};
}
REGISTER_COMPONENT(console::component)