Add setting for specifying custom framerate when window is not active
This commit is contained in:
@@ -176,6 +176,7 @@ Window* GameBase::CreateMainWindow()
|
||||
settings.AllowMinimize = true;
|
||||
settings.Size = Platform::GetDesktopSize();
|
||||
settings.Position = Float2::Zero;
|
||||
settings.WindowFPSWhenNotFocused = 0;
|
||||
|
||||
Game::InitMainWindowSettings(settings);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MMethod.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MClass.h"
|
||||
#include "Engine/Engine/Time.h"
|
||||
|
||||
#if USE_CSHARP
|
||||
// Helper macros for calling C# events
|
||||
@@ -436,6 +437,9 @@ void WindowBase::OnGotFocus()
|
||||
return;
|
||||
_focused = true;
|
||||
|
||||
if (RenderTask && _settings.WindowFPSWhenNotFocused > ZeroTolerance)
|
||||
RenderTask->RenderFPS = 0;
|
||||
|
||||
GotFocus();
|
||||
INVOKE_EVENT_PARAMS_0(OnGotFocus);
|
||||
}
|
||||
@@ -446,6 +450,9 @@ void WindowBase::OnLostFocus()
|
||||
return;
|
||||
_focused = false;
|
||||
|
||||
if (RenderTask && _settings.WindowFPSWhenNotFocused > ZeroTolerance)
|
||||
RenderTask->RenderFPS = _settings.WindowFPSWhenNotFocused;
|
||||
|
||||
LostFocus();
|
||||
INVOKE_EVENT_PARAMS_0(OnLostFocus);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace FlaxEngine
|
||||
IsRegularWindow = true,
|
||||
HasSizingFrame = true,
|
||||
ShowAfterFirstPaint = true,
|
||||
WindowFPSWhenNotFocused = 2,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(CreateWindowSettings);
|
||||
/// </summary>
|
||||
API_FIELD() bool ShowAfterFirstPaint = true;
|
||||
|
||||
/// <summary>
|
||||
/// Custom framerate limit for window rendering when the window is not focused.
|
||||
/// </summary>
|
||||
API_FIELD() int WindowFPSWhenNotFocused = 2;
|
||||
|
||||
/// <summary>
|
||||
/// The custom data (platform dependant).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user