// Console commands of the UI track (DESIGN_UE.md section 9.3): Descent.UI.Open / Close / Tab, and Descent.UI.Demo. #include "Debug/DescentCommandUtil.h" #include "TheDescent.h" #include "UI/DescentUiSubsystem.h" #include "HAL/IConsoleManager.h" namespace { void CmdUiOpen(const TArray& Args, UWorld* World) { UDescentUiSubsystem* Ui = UDescentUiSubsystem::Get(World); if (!Ui || Args.Num() < 1) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Open"), TEXT("usage: Descent.UI.Open (needs a running game)")); return; } if (!Ui->OpenByName(Args[0])) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Open"), FString::Printf(TEXT("'%s' is not a window"), *Args[0])); return; } UE_LOG(LogDescent, Display, TEXT("UI.Open: %s, tab %s"), *Args[0], *Ui->GetTab().ToString()); } void CmdUiClose(const TArray&, UWorld* World) { UDescentUiSubsystem* Ui = UDescentUiSubsystem::Get(World); if (!Ui) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Close"), TEXT("needs a running game")); return; } Ui->Close(); UE_LOG(LogDescent, Display, TEXT("UI.Close: no window is open")); } void CmdUiTab(const TArray& Args, UWorld* World) { UDescentUiSubsystem* Ui = UDescentUiSubsystem::Get(World); if (!Ui || Args.Num() < 1) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Tab"), TEXT("usage: Descent.UI.Tab (a window must be open)")); return; } if (!Ui->SetTab(FName(*Args[0].ToLower()))) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Tab"), FString::Printf(TEXT("'%s' is not a tab of the open window"), *Args[0])); return; } UE_LOG(LogDescent, Display, TEXT("UI.Tab: %s"), *Args[0]); } void CmdUiDemo(const TArray& Args, UWorld* World) { UDescentUiSubsystem* Ui = UDescentUiSubsystem::Get(World); bool bValid = false; const bool bOn = Args.Num() > 0 ? Descent::Cmd::ParseBool(Args[0], bValid) : false; if (!Ui || !bValid) { Descent::Cmd::Fail(World, TEXT("Descent.UI.Demo"), TEXT("usage: Descent.UI.Demo <0 or 1> (needs a running game)")); return; } Ui->SetDemo(bOn); UE_LOG(LogDescent, Display, TEXT("UI.Demo: %s"), bOn ? TEXT("on, HUD model and all view-models filled") : TEXT("off, cleared")); } FAutoConsoleCommandWithWorldAndArgs GUiCmdOpen(TEXT("Descent.UI.Open"), TEXT("Descent.UI.Open - open pda|map|logs|status|fabricator|refinery|packer|storage|terminal|vat|build|pause|title|end"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdUiOpen)); FAutoConsoleCommandWithWorldAndArgs GUiCmdClose(TEXT("Descent.UI.Close"), TEXT("Descent.UI.Close - close the open window"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdUiClose)); FAutoConsoleCommandWithWorldAndArgs GUiCmdTab(TEXT("Descent.UI.Tab"), TEXT("Descent.UI.Tab - switch the tab of the open window (PDA: inventory, map, logs, status)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdUiTab)); FAutoConsoleCommandWithWorldAndArgs GUiCmdDemo(TEXT("Descent.UI.Demo"), TEXT("Descent.UI.Demo <0 or 1> - fill the HUD model and every window view-model with demo data (0 clears)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdUiDemo)); }