Correctly implement the ScreenUtils class
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#include "ScreenUtilsBase.h"
|
||||
#include "Engine/Core/Math/Color32.h"
|
||||
#include "Engine/Core/Math/Vector2.h"
|
||||
|
||||
Color32 ScreenUtilsBase::GetPixelAt(int32 x, int32 y) {
|
||||
return Color32::Black;
|
||||
}
|
||||
|
||||
Int2 ScreenUtilsBase::GetScreenCursorPosition() {
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Types/BaseTypes.h"
|
||||
|
||||
API_INJECT_CODE(cpp, "#include \"Engine/Platform/ScreenUtils.h\"");
|
||||
|
||||
/// <summary>
|
||||
/// Platform-dependent screen utilties.
|
||||
/// </summary>
|
||||
API_CLASS(Static, Name = "ScreenUtils", Tag = "NativeInvokeUseName")
|
||||
class FLAXENGINE_API ScreenUtilsBase
|
||||
{
|
||||
public:
|
||||
static struct FLAXENGINE_API ScriptingTypeInitializer TypeInitializer;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pixel color at the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x">X Coordinate to read.</param>
|
||||
/// <param name="y">Y Coordinate to read.</param>
|
||||
/// <returns>Pixel color at the specified coordinates.</returns>
|
||||
API_FUNCTION() static Color32 GetPixelAt(int32 x, int32 y);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cursor position, in screen cooridnates.
|
||||
/// </summary>
|
||||
/// <returns>Cursor position, in screen coordinates.</returns>
|
||||
API_FUNCTION() static Int2 GetScreenCursorPosition();
|
||||
};
|
||||
|
||||
@@ -9,9 +9,3 @@
|
||||
#endif
|
||||
|
||||
#include "Types.h"
|
||||
#include "Engine/Scripting/ScriptingType.h"
|
||||
|
||||
API_CLASS(Static) class FLAXENGINE_API ScreenUtils
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_NO_SPAWN(ScreenUtils);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
Color32 PlatformScreenUtils::GetPixelAt(int32 x, int32 y) {
|
||||
#if PLATFORM_WINDOWS
|
||||
#pragma comment(lib, "Gdi32.lib")
|
||||
#endif
|
||||
|
||||
Color32 ScreenUtils::GetPixelAt(int32 x, int32 y) {
|
||||
HDC deviceContext = GetDC(NULL);
|
||||
COLORREF color = GetPixel(deviceContext, x, y);
|
||||
ReleaseDC(NULL, deviceContext);
|
||||
@@ -13,7 +17,7 @@ Color32 PlatformScreenUtils::GetPixelAt(int32 x, int32 y) {
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
Int2 PlatformScreenUtils::GetScreenCursorPosition() {
|
||||
Int2 ScreenUtils::GetScreenCursorPosition() {
|
||||
POINT cursorPos;
|
||||
GetCursorPos(&cursorPos);
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
#include "Engine/Core/Math/Color32.h"
|
||||
|
||||
class PlatformScreenUtils {
|
||||
#if PLATFORM_WINDOWS
|
||||
|
||||
#include "Engine/Core/Math/Color32.h"
|
||||
#include "Engine/Platform/Base/ScreenUtilsBase.h"
|
||||
|
||||
class FLAXENGINE_API ScreenUtils : public ScreenUtilsBase {
|
||||
public:
|
||||
|
||||
// [ScreenUtilsBase]
|
||||
static Color32 GetPixelAt(int32 x, int32 y);
|
||||
static Int2 GetScreenCursorPosition();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user