// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Scripting/ScriptingType.h"
///
/// Debug commands and console variables system.
///
API_CLASS(static) class FLAXENGINE_API DebugCommands
{
DECLARE_SCRIPTING_TYPE_MINIMAL(DebugCommands);
// Types of debug command flags.
API_ENUM(Attributes="Flags") enum class CommandFlags
{
// Incorrect or missing command.
None = 0,
// Executable method.
Exec = 1,
// Can get value.
Read = 2,
// Can set value.
Write = 4,
// Can get and set value.
ReadWrite = Read | Write,
};
public:
///
/// Executes the command.
///
/// The command line (optionally with arguments).
API_FUNCTION() static void Execute(StringView command);
///
/// Searches the list of commands to return candidates that match the given query text.
///
/// The query text.
/// The output list of commands that match a given query (unsorted).
/// True if filter commands that start with a specific search text, otherwise will return commands that contain a specific query.
API_FUNCTION() static void Search(StringView searchText, API_PARAM(Out) Array& matches, bool startsWith = false);
///
/// Starts asynchronous debug commands caching. Cna be used to minimize time-to-interactive when using console interface or when using scripted actions.
///
API_FUNCTION() static void InitAsync();
///
/// Returns flags of the command.
///
/// The full name of the command.
API_FUNCTION() static CommandFlags GetCommandFlags(StringView command);
public:
static bool Iterate(const StringView& searchText, int32& index);
static StringView GetCommandName(int32 index);
};
DECLARE_ENUM_OPERATORS(DebugCommands::CommandFlags);