244 lines
7.2 KiB
C++
244 lines
7.2 KiB
C++
// Copyright (c) Wojciech Figat. All rights reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Engine/Core/Types/String.h"
|
|
#include "Engine/Core/Types/StringView.h"
|
|
#include "Engine/Core/Types/Nullable.h"
|
|
|
|
/// <summary>
|
|
/// Command line options helper.
|
|
/// </summary>
|
|
class FLAXENGINE_API CommandLine
|
|
{
|
|
public:
|
|
struct OptionsData
|
|
{
|
|
/// <summary>
|
|
/// The command line.
|
|
/// </summary>
|
|
const Char* CmdLine = nullptr;
|
|
|
|
/// <summary>
|
|
/// -widowed (use windowed mode)
|
|
/// </summary>
|
|
Nullable<bool> Windowed;
|
|
|
|
/// <summary>
|
|
/// -fullscreen (use fullscreen)
|
|
/// </summary>
|
|
Nullable<bool> Fullscreen;
|
|
|
|
/// <summary>
|
|
/// -vsync (enable vertical synchronization)
|
|
/// </summary>
|
|
Nullable<bool> VSync;
|
|
|
|
/// <summary>
|
|
/// -novsync (disable vertical synchronization)
|
|
/// </summary>
|
|
Nullable<bool> NoVSync;
|
|
|
|
/// <summary>
|
|
/// -nolog (disable output log file)
|
|
/// </summary>
|
|
Nullable<bool> NoLog;
|
|
|
|
/// <summary>
|
|
/// -std (redirect log to standard output)
|
|
/// </summary>
|
|
Nullable<bool> Std;
|
|
|
|
#if PLATFORM_HAS_HEADLESS_MODE
|
|
|
|
/// <summary>
|
|
/// -headless (Run without windows, used by CL)
|
|
/// </summary>
|
|
Nullable<bool> Headless;
|
|
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// -d3d12 (forces to use DirectX 12 rendering backend if available)
|
|
/// </summary>
|
|
Nullable<bool> D3D12;
|
|
|
|
/// <summary>
|
|
/// -d3d11 (forces to use DirectX 11 rendering backend if available)
|
|
/// </summary>
|
|
Nullable<bool> D3D11;
|
|
|
|
/// <summary>
|
|
/// -d3d10 (forces to use DirectX 10 rendering backend if available)
|
|
/// </summary>
|
|
Nullable<bool> D3D10;
|
|
|
|
/// <summary>
|
|
/// -null (forces to use Null rendering backend if available)
|
|
/// </summary>
|
|
Nullable<bool> Null;
|
|
|
|
/// <summary>
|
|
/// -vulkan (forces to use Vulkan rendering backend if available)
|
|
/// </summary>
|
|
Nullable<bool> Vulkan;
|
|
|
|
/// <summary>
|
|
/// -nvidia (hints to use NVIDIA GPU if available)
|
|
/// </summary>
|
|
Nullable<bool> NVIDIA;
|
|
|
|
/// <summary>
|
|
/// -amd (hints to use AMD GPU if available)
|
|
/// </summary>
|
|
Nullable<bool> AMD;
|
|
|
|
/// <summary>
|
|
/// -intel (hints to use Intel GPU if available)
|
|
/// </summary>
|
|
Nullable<bool> Intel;
|
|
|
|
/// <summary>
|
|
/// -mute (disables audio playback and uses Null Audio Backend)
|
|
/// </summary>
|
|
Nullable<bool> Mute;
|
|
|
|
/// <summary>
|
|
/// -lowdpi (disables High DPI awareness support)
|
|
/// </summary>
|
|
Nullable<bool> LowDPI;
|
|
|
|
#if PLATFORM_LINUX && PLATFORM_SDL
|
|
|
|
/// <summary>
|
|
/// -wayland (prefer Wayland over X11 as display server)
|
|
/// </summary>
|
|
Nullable<bool> Wayland;
|
|
|
|
/// <summary>
|
|
/// -x11 (prefer X11 over Wayland as display server)
|
|
/// </summary>
|
|
Nullable<bool> X11;
|
|
|
|
#endif
|
|
|
|
#if USE_EDITOR
|
|
/// <summary>
|
|
/// -project=<path> (Startup project path)
|
|
/// </summary>
|
|
String Project;
|
|
|
|
/// <summary>
|
|
/// -lastproject (Opens the last project)
|
|
/// </summary>
|
|
Nullable<bool> LastProject;
|
|
|
|
/// <summary>
|
|
/// -new (generates the project files inside the specified project folder or uses current workspace folder)
|
|
/// </summary>
|
|
Nullable<bool> NewProject;
|
|
|
|
/// <summary>
|
|
/// -genprojectfiles (generates the scripts project files)
|
|
/// </summary>
|
|
Nullable<bool> GenProjectFiles;
|
|
|
|
/// <summary>
|
|
/// -clearcache (clear project cache folder)
|
|
/// </summary>
|
|
Nullable<bool> ClearCache;
|
|
|
|
/// <summary>
|
|
/// -clearcooker (clear Game Cooker cache folder)
|
|
/// </summary>
|
|
Nullable<bool> ClearCookerCache;
|
|
|
|
/// <summary>
|
|
/// The build preset (-build=<preset.target> or -build=<preset>) (run game building on startup and exit app on end).
|
|
/// </summary>
|
|
Nullable<String> Build;
|
|
|
|
/// <summary>
|
|
/// -skipcompile (skips the scripts compilation on editor startup, useful when launching engine from IDE)
|
|
/// </summary>
|
|
Nullable<bool> SkipCompile;
|
|
|
|
/// <summary>
|
|
/// -shaderdebug (enables debugging data generation for shaders and disables shader compiler optimizations)
|
|
/// </summary>
|
|
Nullable<bool> ShaderDebug;
|
|
|
|
/// <summary>
|
|
/// -exit (exits the editor after startup and performing all queued actions). Usefull when invoking editor from CL/CD.
|
|
/// </summary>
|
|
Nullable<bool> Exit;
|
|
|
|
/// <summary>
|
|
/// -play=<guid> ( Scene to play, can be empty to use default )
|
|
/// </summary>
|
|
Nullable<String> Play;
|
|
#endif
|
|
|
|
#if USE_EDITOR || !BUILD_RELEASE
|
|
/// <summary>
|
|
/// -shaderprofile (enables debugging data generation for shaders but leaves shader compiler optimizations active for performance profiling)
|
|
/// </summary>
|
|
Nullable<bool> ShaderProfile;
|
|
|
|
/// <summary>
|
|
/// -gpudebug (activates GPU Debug Layers and additional assertions for rendering validation)
|
|
/// </summary>
|
|
Nullable<bool> GPUDebug;
|
|
#endif
|
|
};
|
|
|
|
/// <summary>
|
|
/// The input options.
|
|
/// </summary>
|
|
static OptionsData Options;
|
|
|
|
public:
|
|
/// <summary>
|
|
/// The command line option data.
|
|
/// </summary>
|
|
struct FLAXENGINE_API Arg
|
|
{
|
|
// The name.
|
|
StringView Name;
|
|
// The value.
|
|
StringView Value;
|
|
};
|
|
|
|
/// <summary>
|
|
/// Gets the specific command line option value. Returns true if given argument has been set.
|
|
/// </summary>
|
|
/// <returns>True if given argument has been provided in program command line.</returns>
|
|
static bool Get(const StringView& arg);
|
|
|
|
/// <summary>
|
|
/// Gets the specific command line option value. Returns true if given argument has been set and provides it's value (as string).
|
|
/// </summary>
|
|
/// <returns>True if given argument has been provided in program command line.</returns>
|
|
static bool Get(const StringView& arg, StringView& value);
|
|
|
|
/// <summary>
|
|
/// Gets the specific command line option value. Returns true if given argument has been set and provides it's value (as boolean). Returns ture if argument doesn't have specific value.
|
|
/// </summary>
|
|
/// <returns>True if given argument has been provided in program command line.</returns>
|
|
static bool Get(const StringView& arg, bool& value);
|
|
|
|
/// <summary>
|
|
/// Gets the specific command line option value. Returns true if given argument has been set and provides it's value (as integer).
|
|
/// </summary>
|
|
/// <returns>True if given argument has been provided in program command line.</returns>
|
|
static bool Get(const StringView& arg, int32& value);
|
|
|
|
/// <summary>
|
|
/// Parses the specified command line.
|
|
/// </summary>
|
|
/// <param name="cmdLine">The input command line.</param>
|
|
/// <param name="args">The parsed arguments</param>
|
|
/// <returns>True if failed, otherwise false.</returns>
|
|
static bool Parse(const StringView& cmdLine, Array<Arg, HeapAllocation>& args);
|
|
};
|