Process commandlets without always initializing the entire engine
This commit is contained in:
parent
5491aecd5f
commit
794cfd78c8
12 changed files with 110 additions and 25 deletions
|
|
@ -2,6 +2,45 @@
|
|||
#include "commandlet.h"
|
||||
#include "lightmapcmd.h"
|
||||
#include "version.h"
|
||||
#include <functional>
|
||||
|
||||
int D_DoomMain_Game();
|
||||
static std::function<void()>* ToolCallback;
|
||||
extern bool DisableLogging;
|
||||
|
||||
int ToolMain()
|
||||
{
|
||||
RootCommandlet commands;
|
||||
commands.RunCommand();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Commandlet::RunInGame(std::function<void()> action)
|
||||
{
|
||||
std::function<void()> callback = [=]() {
|
||||
DisableLogging = false;
|
||||
action();
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
bool verbose = Args->CheckParm("-verbose") != 0;
|
||||
if (!verbose)
|
||||
DisableLogging = true;
|
||||
ToolCallback = &callback;
|
||||
D_DoomMain_Game();
|
||||
ToolCallback = nullptr;
|
||||
DisableLogging = false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ToolCallback = nullptr;
|
||||
DisableLogging = false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CommandletGroup::AddGroup(std::unique_ptr<CommandletGroup> group)
|
||||
{
|
||||
|
|
@ -20,6 +59,12 @@ RootCommandlet::RootCommandlet()
|
|||
AddGroup<LightmapCmdletGroup>();
|
||||
}
|
||||
|
||||
void RootCommandlet::RunEngineCommand()
|
||||
{
|
||||
if (ToolCallback)
|
||||
(*ToolCallback)();
|
||||
}
|
||||
|
||||
void RootCommandlet::RunCommand()
|
||||
{
|
||||
FArgs args = *Args;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue