Merge branch 'game-arg' of git://github.com/jb-perrier/FlaxEngine into jb-perrier-game-arg
This commit is contained in:
@@ -518,7 +518,7 @@ bool Editor::Init()
|
|||||||
exit(failed ? 1 : 0);
|
exit(failed ? 1 : 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If during last lightmaps baking engine crashed we could try to restore the progress
|
// If during last lightmaps baking engine crashed we could try to restore the progress
|
||||||
ShadowsOfMordor::Builder::Instance()->CheckIfRestoreState();
|
ShadowsOfMordor::Builder::Instance()->CheckIfRestoreState();
|
||||||
|
|
||||||
@@ -534,6 +534,12 @@ bool Editor::Init()
|
|||||||
// Initialize managed editor
|
// Initialize managed editor
|
||||||
Managed->Init();
|
Managed->Init();
|
||||||
|
|
||||||
|
// Start play if requested by cmd line
|
||||||
|
if (CommandLine::Options.Play.HasValue())
|
||||||
|
{
|
||||||
|
Managed->RequestStartPlayOnEditMode();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace FlaxEditor
|
|||||||
private bool _isAfterInit, _areModulesInited, _areModulesAfterInitEnd, _isHeadlessMode;
|
private bool _isAfterInit, _areModulesInited, _areModulesAfterInitEnd, _isHeadlessMode;
|
||||||
private string _projectToOpen;
|
private string _projectToOpen;
|
||||||
private float _lastAutoSaveTimer;
|
private float _lastAutoSaveTimer;
|
||||||
|
private Guid _startupSceneCmdLine;
|
||||||
|
|
||||||
private const string ProjectDataLastScene = "LastScene";
|
private const string ProjectDataLastScene = "LastScene";
|
||||||
private const string ProjectDataLastSceneSpawn = "LastSceneSpawn";
|
private const string ProjectDataLastSceneSpawn = "LastSceneSpawn";
|
||||||
@@ -271,10 +272,11 @@ namespace FlaxEditor
|
|||||||
module.OnEndInit();
|
module.OnEndInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Init(bool isHeadless, bool skipCompile)
|
internal void Init(bool isHeadless, bool skipCompile, Guid startupScene)
|
||||||
{
|
{
|
||||||
EnsureState<LoadingState>();
|
EnsureState<LoadingState>();
|
||||||
_isHeadlessMode = isHeadless;
|
_isHeadlessMode = isHeadless;
|
||||||
|
_startupSceneCmdLine = startupScene;
|
||||||
Log("Editor init");
|
Log("Editor init");
|
||||||
if (isHeadless)
|
if (isHeadless)
|
||||||
Log("Running in headless mode");
|
Log("Running in headless mode");
|
||||||
@@ -332,6 +334,17 @@ namespace FlaxEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load scene
|
// Load scene
|
||||||
|
|
||||||
|
// scene cmd line argument
|
||||||
|
var scene = ContentDatabase.Find(_startupSceneCmdLine);
|
||||||
|
if (scene is SceneItem)
|
||||||
|
{
|
||||||
|
Editor.Log("Loading scene specified in command line");
|
||||||
|
Scene.OpenScene(_startupSceneCmdLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no scene cmd line argument is provided
|
||||||
var startupSceneMode = Options.Options.General.StartupSceneMode;
|
var startupSceneMode = Options.Options.General.StartupSceneMode;
|
||||||
if (startupSceneMode == GeneralOptions.StartupSceneModes.LastOpened && !ProjectCache.HasCustomData(ProjectDataLastScene))
|
if (startupSceneMode == GeneralOptions.StartupSceneModes.LastOpened && !ProjectCache.HasCustomData(ProjectDataLastScene))
|
||||||
{
|
{
|
||||||
@@ -1309,6 +1322,19 @@ namespace FlaxEditor
|
|||||||
AnimGraphDebugFlow?.Invoke(debugFlow);
|
AnimGraphDebugFlow?.Invoke(debugFlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void RequestStartPlayOnEditMode()
|
||||||
|
{
|
||||||
|
if (Instance.StateMachine.IsEditMode)
|
||||||
|
Instance.Simulation.RequestStartPlay();
|
||||||
|
if (Instance.StateMachine.IsPlayMode)
|
||||||
|
Instance.StateMachine.StateChanged -= RequestStartPlayOnEditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Internal_RequestStartPlayOnEditMode()
|
||||||
|
{
|
||||||
|
Instance.StateMachine.StateChanged += RequestStartPlayOnEditMode;
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
internal static extern int Internal_ReadOutputLogs(string[] outMessages, byte[] outLogTypes, long[] outLogTimes);
|
internal static extern int Internal_ReadOutputLogs(string[] outMessages, byte[] outLogTypes, long[] outLogTimes);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ MMethod* Internal_GetGameWindowSize = nullptr;
|
|||||||
MMethod* Internal_OnAppExit = nullptr;
|
MMethod* Internal_OnAppExit = nullptr;
|
||||||
MMethod* Internal_OnVisualScriptingDebugFlow = nullptr;
|
MMethod* Internal_OnVisualScriptingDebugFlow = nullptr;
|
||||||
MMethod* Internal_OnAnimGraphDebugFlow = nullptr;
|
MMethod* Internal_OnAnimGraphDebugFlow = nullptr;
|
||||||
|
MMethod* Internal_RequestStartPlayOnEditMode = nullptr;
|
||||||
|
|
||||||
void OnLightmapsBake(ShadowsOfMordor::BuildProgressStep step, float stepProgress, float totalProgress, bool isProgressEvent)
|
void OnLightmapsBake(ShadowsOfMordor::BuildProgressStep step, float stepProgress, float totalProgress, bool isProgressEvent)
|
||||||
{
|
{
|
||||||
@@ -209,7 +210,7 @@ ManagedEditor::~ManagedEditor()
|
|||||||
void ManagedEditor::Init()
|
void ManagedEditor::Init()
|
||||||
{
|
{
|
||||||
// Note: editor modules should perform quite fast init, any longer things should be done in async during 'editor splash screen time
|
// Note: editor modules should perform quite fast init, any longer things should be done in async during 'editor splash screen time
|
||||||
void* args[2];
|
void* args[3];
|
||||||
MClass* mclass = GetClass();
|
MClass* mclass = GetClass();
|
||||||
if (mclass == nullptr)
|
if (mclass == nullptr)
|
||||||
{
|
{
|
||||||
@@ -230,6 +231,12 @@ void ManagedEditor::Init()
|
|||||||
bool skipCompile = CommandLine::Options.SkipCompile.IsTrue();
|
bool skipCompile = CommandLine::Options.SkipCompile.IsTrue();
|
||||||
args[0] = &isHeadless;
|
args[0] = &isHeadless;
|
||||||
args[1] = &skipCompile;
|
args[1] = &skipCompile;
|
||||||
|
Guid sceneId;
|
||||||
|
if (!CommandLine::Options.Play.HasValue() || (CommandLine::Options.Play.HasValue() && Guid::Parse(CommandLine::Options.Play.GetValue(), sceneId)))
|
||||||
|
{
|
||||||
|
sceneId = Guid::Empty;
|
||||||
|
}
|
||||||
|
args[2] = &sceneId;
|
||||||
initMethod->Invoke(instance, args, &exception);
|
initMethod->Invoke(instance, args, &exception);
|
||||||
if (exception)
|
if (exception)
|
||||||
{
|
{
|
||||||
@@ -481,6 +488,18 @@ bool ManagedEditor::OnAppExit()
|
|||||||
return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr));
|
return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ManagedEditor::RequestStartPlayOnEditMode()
|
||||||
|
{
|
||||||
|
if (!HasManagedInstance())
|
||||||
|
return;
|
||||||
|
if (Internal_RequestStartPlayOnEditMode == nullptr)
|
||||||
|
{
|
||||||
|
Internal_RequestStartPlayOnEditMode = GetClass()->GetMethod("Internal_RequestStartPlayOnEditMode");
|
||||||
|
ASSERT(Internal_RequestStartPlayOnEditMode);
|
||||||
|
}
|
||||||
|
Internal_RequestStartPlayOnEditMode->Invoke(GetManagedInstance(), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void ManagedEditor::OnEditorAssemblyLoaded(MAssembly* assembly)
|
void ManagedEditor::OnEditorAssemblyLoaded(MAssembly* assembly)
|
||||||
{
|
{
|
||||||
ASSERT(!HasManagedInstance());
|
ASSERT(!HasManagedInstance());
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ public:
|
|||||||
/// <returns>True if exit engine, otherwise false.</returns>
|
/// <returns>True if exit engine, otherwise false.</returns>
|
||||||
bool OnAppExit();
|
bool OnAppExit();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests play mode when the editor is in edit mode ( once ).
|
||||||
|
/// </summary>
|
||||||
|
void RequestStartPlayOnEditMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnEditorAssemblyLoaded(MAssembly* assembly);
|
void OnEditorAssemblyLoaded(MAssembly* assembly);
|
||||||
|
|||||||
@@ -102,6 +102,23 @@ bool CommandLine::Parse(const Char* cmdLine)
|
|||||||
*(end - len) = 0; \
|
*(end - len) = 0; \
|
||||||
end -= len; \
|
end -= len; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PARSE_ARG_OPT_SWITCH(text, field) \
|
||||||
|
pos = (Char*)StringUtils::FindIgnoreCase(buffer.Get(), TEXT(text)); \
|
||||||
|
if (pos) \
|
||||||
|
{ \
|
||||||
|
len = ARRAY_COUNT(text) - 1; \
|
||||||
|
if (ParseArg(pos + len, argStart, argEnd)) \
|
||||||
|
Options.field = String::Empty; \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
Options.field = String(argStart, static_cast<int32>(argEnd - argStart)); \
|
||||||
|
len = static_cast<int32>((argEnd - pos) + 1); \
|
||||||
|
Platform::MemoryCopy(pos, pos + len, (end - pos - len) * 2); \
|
||||||
|
*(end - len) = 0; \
|
||||||
|
end -= len; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
PARSE_BOOL_SWITCH("-windowed ", Windowed);
|
PARSE_BOOL_SWITCH("-windowed ", Windowed);
|
||||||
PARSE_BOOL_SWITCH("-fullscreen ", Fullscreen);
|
PARSE_BOOL_SWITCH("-fullscreen ", Fullscreen);
|
||||||
@@ -137,6 +154,7 @@ bool CommandLine::Parse(const Char* cmdLine)
|
|||||||
PARSE_ARG_SWITCH("-build ", Build);
|
PARSE_ARG_SWITCH("-build ", Build);
|
||||||
PARSE_BOOL_SWITCH("-skipcompile ", SkipCompile);
|
PARSE_BOOL_SWITCH("-skipcompile ", SkipCompile);
|
||||||
PARSE_BOOL_SWITCH("-shaderdebug ", ShaderDebug);
|
PARSE_BOOL_SWITCH("-shaderdebug ", ShaderDebug);
|
||||||
|
PARSE_ARG_OPT_SWITCH("-play ", Play);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Nullable<bool> ShaderDebug;
|
Nullable<bool> ShaderDebug;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// -play !guid! ( Scene to play, can be empty to use default )
|
||||||
|
/// </summary>
|
||||||
|
Nullable<String> Play;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -363,7 +363,8 @@ void Mesh::GetDrawCallGeometry(DrawCall& drawCall) const
|
|||||||
|
|
||||||
void Mesh::Render(GPUContext* context) const
|
void Mesh::Render(GPUContext* context) const
|
||||||
{
|
{
|
||||||
ASSERT(IsInitialized());
|
if (!IsInitialized())
|
||||||
|
return;
|
||||||
|
|
||||||
context->BindVB(ToSpan((GPUBuffer**)_vertexBuffers, 3));
|
context->BindVB(ToSpan((GPUBuffer**)_vertexBuffers, 3));
|
||||||
context->BindIB(_indexBuffer);
|
context->BindIB(_indexBuffer);
|
||||||
@@ -372,7 +373,7 @@ void Mesh::Render(GPUContext* context) const
|
|||||||
|
|
||||||
void Mesh::Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags, bool receiveDecals, DrawPass drawModes, float perInstanceRandom) const
|
void Mesh::Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags, bool receiveDecals, DrawPass drawModes, float perInstanceRandom) const
|
||||||
{
|
{
|
||||||
if (!material || !material->IsSurface())
|
if (!material || !material->IsSurface() || !IsInitialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Submit draw call
|
// Submit draw call
|
||||||
|
|||||||
Reference in New Issue
Block a user