This commit is contained in:
stefnotch
2021-02-08 09:48:46 +01:00
parent f9deb97229
commit c7feeb624d
7 changed files with 12 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ namespace FlaxEditor.Content
if (asset)
{
var source = Editor.GetShaderSourceCode(asset);
Utilities.Utils.ShowSourceCodeWindow(source, "Shader Source");
Utilities.Utils.ShowSourceCodeWindow(source, "Shader Source", item.RootWindow.Window);
}
return null;
}

View File

@@ -1643,7 +1643,8 @@ namespace FlaxEditor.Utilities
/// </summary>
/// <param name="source">The source code.</param>
/// <param name="title">The window title.</param>
public static void ShowSourceCodeWindow(string source, string title)
/// <param name="parentWindow">The optional parent window.</param>
public static void ShowSourceCodeWindow(string source, string title, Window parentWindow = null)
{
if (string.IsNullOrEmpty(source))
{
@@ -1656,8 +1657,9 @@ namespace FlaxEditor.Utilities
settings.AllowMaximize = false;
settings.AllowMinimize = false;
settings.HasSizingFrame = false;
settings.StartPosition = WindowStartPosition.CenterScreen;
settings.Size = new Vector2(500, 600) * Platform.DpiScale; // TODO: Place the window on the correct screen (and use that screen's size)
settings.StartPosition = WindowStartPosition.CenterParent;
settings.Size = new Vector2(500, 600) * (parentWindow?.DpiScale ?? Platform.DpiScale);
settings.Parent = parentWindow;
settings.Title = title;
var dialog = Platform.CreateWindow(ref settings);

View File

@@ -241,10 +241,10 @@ namespace FlaxEditor.Windows.Assets
/// Shows the material source code window.
/// </summary>
/// <param name="material">The material asset.</param>
public static void ShowSourceCode(Material material)
public void ShowSourceCode(Material material)
{
var source = Editor.GetShaderSourceCode(material);
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source");
Utilities.Utils.ShowSourceCodeWindow(source, "Material Source", RootWindow.Window);
}
/// <summary>

View File

@@ -147,10 +147,10 @@ namespace FlaxEditor.Windows.Assets
/// Shows the ParticleEmitter source code window.
/// </summary>
/// <param name="particleEmitter">The ParticleEmitter asset.</param>
public static void ShowSourceCode(ParticleEmitter particleEmitter)
public void ShowSourceCode(ParticleEmitter particleEmitter)
{
var source = Editor.GetShaderSourceCode(particleEmitter);
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source");
Utilities.Utils.ShowSourceCodeWindow(source, "Particle Emitter GPU Simulation Source", RootWindow.Window);
}
/// <inheritdoc />

View File

@@ -551,7 +551,6 @@ public:
return _dpi;
}
// TODO: This doesn't actually include the custom DPI scale
/// <summary>
/// Gets the window DPI scale factor (1 is default). Includes custom DPI scale
/// </summary>

View File

@@ -58,7 +58,7 @@ int32 CalculateDpi(HMODULE shCoreDll)
if (getDPIForMonitor)
{
HMONITOR monitor = GetPrimaryMonitorHandle(); // TODO: Use the game window monitor
HMONITOR monitor = GetPrimaryMonitorHandle();
UINT x = 0, y = 0;
HRESULT hr = getDPIForMonitor(monitor, 0, &x, &y);

View File

@@ -99,7 +99,7 @@ WindowsWindow::WindowsWindow(const CreateWindowSettings& settings)
nullptr);
_dpi = DefaultDPI;
// TODO: Is this the correct way of doing this?
const HMODULE user32Dll = LoadLibraryW(L"user32.dll");
if (user32Dll)
{