Implement SDL platform, windowing and input handling
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
|
||||
#include "WindowsWindow.h"
|
||||
#include "WindowsFileSystem.h"
|
||||
#include "Engine/Platform/File.h"
|
||||
#include "Engine/Platform/Window.h"
|
||||
@@ -317,7 +318,7 @@ bool WindowsFileSystem::ShowBrowseFolderDialog(Window* parentWindow, const Strin
|
||||
if (SUCCEEDED(SHCreateItemFromParsingName(initialDirectory.Get(), NULL, IID_PPV_ARGS(&defaultFolder))))
|
||||
fd->SetFolder(defaultFolder);
|
||||
|
||||
HWND hwndOwner = parentWindow ? parentWindow->GetHWND() : NULL;
|
||||
HWND hwndOwner = parentWindow ? (HWND)parentWindow->GetNativePtr() : NULL;
|
||||
if (SUCCEEDED(fd->Show(hwndOwner)))
|
||||
{
|
||||
ComPtr<IShellItem> si;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#if PLATFORM_WINDOWS && !PLATFORM_SDL
|
||||
|
||||
#include "WindowsInput.h"
|
||||
#include "WindowsWindow.h"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Platform/Window.h"
|
||||
#include "Engine/Platform/Windows/WindowsInput.h"
|
||||
#include "Engine/Platform/Windows/WindowsWindow.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Platform/CreateWindowSettings.h"
|
||||
#include "Engine/Platform/CreateProcessSettings.h"
|
||||
@@ -255,6 +257,8 @@ void GetWindowsVersion(String& windowsName, int32& versionMajor, int32& versionM
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Find window to process that message
|
||||
@@ -272,6 +276,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
long __stdcall WindowsPlatform::SehExceptionHandler(EXCEPTION_POINTERS* ep)
|
||||
{
|
||||
if (ep->ExceptionRecord->ExceptionCode == CLR_EXCEPTION)
|
||||
@@ -518,6 +524,7 @@ void WindowsPlatform::PreInit(void* hInstance)
|
||||
// Disable the process from being showing "ghosted" while not responding messages during slow tasks
|
||||
DisableProcessWindowsGhosting();
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
// Register window class
|
||||
WNDCLASS windowsClass;
|
||||
Platform::MemoryClear(&windowsClass, sizeof(WNDCLASS));
|
||||
@@ -532,6 +539,7 @@ void WindowsPlatform::PreInit(void* hInstance)
|
||||
Error(TEXT("Window class registration failed!"));
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Init OLE
|
||||
if (OleInitialize(nullptr) != S_OK)
|
||||
@@ -680,7 +688,9 @@ bool WindowsPlatform::Init()
|
||||
}
|
||||
OnPlatformUserAdd(New<User>(userName));
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
WindowsInput::Init();
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -708,7 +718,9 @@ void WindowsPlatform::LogInfo()
|
||||
|
||||
void WindowsPlatform::Tick()
|
||||
{
|
||||
#if !PLATFORM_SDL
|
||||
WindowsInput::Update();
|
||||
#endif
|
||||
|
||||
// Check to see if any messages are waiting in the queue
|
||||
MSG msg;
|
||||
@@ -739,8 +751,10 @@ void WindowsPlatform::Exit()
|
||||
DbgHelpUnlock();
|
||||
#endif
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
// Unregister app class
|
||||
UnregisterClassW(ApplicationClassName, nullptr);
|
||||
#endif
|
||||
|
||||
Win32Platform::Exit();
|
||||
}
|
||||
@@ -1185,11 +1199,15 @@ int32 WindowsPlatform::CreateProcess(CreateProcessSettings& settings)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
|
||||
Window* WindowsPlatform::CreateWindow(const CreateWindowSettings& settings)
|
||||
{
|
||||
return New<WindowsWindow>(settings);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void* WindowsPlatform::LoadLibrary(const Char* filename)
|
||||
{
|
||||
ASSERT(filename);
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
|
||||
#if PLATFORM_SDL
|
||||
#include "Engine/Platform/SDL/SDLWindow.h"
|
||||
#endif
|
||||
|
||||
#include "Engine/Platform/Windows/WindowsWindow.h"
|
||||
|
||||
#if USE_EDITOR
|
||||
@@ -596,7 +600,11 @@ DragDropEffect Window::DoDragDrop(const StringView& data)
|
||||
{
|
||||
::POINT point;
|
||||
::GetCursorPos(&point);
|
||||
#if PLATFORM_SDL
|
||||
Input::Mouse->OnMouseUp(Float2((float)point.x, (float)point.y), MouseButton::Left, (Window*)this);
|
||||
#else
|
||||
Input::Mouse->OnMouseUp(Float2((float)point.x, (float)point.y), MouseButton::Left, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
return SUCCEEDED(result) ? dropEffectFromOleEnum(dwEffect) : DragDropEffect::None;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#if PLATFORM_WINDOWS && !PLATFORM_SDL
|
||||
|
||||
#include "WindowsWindow.h"
|
||||
#include "WindowsPlatform.h"
|
||||
@@ -1308,7 +1308,7 @@ LRESULT WindowsWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (_settings.AllowInput)
|
||||
{
|
||||
if (WindowsInput::WndProc(this, msg, wParam, lParam))
|
||||
if (WindowsInput::WndProc((Window*)this, msg, wParam, lParam))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#if PLATFORM_WINDOWS && !PLATFORM_SDL
|
||||
|
||||
#include "Engine/Platform/Base/WindowBase.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
Windows::ULONG __stdcall AddRef() override;
|
||||
Windows::ULONG __stdcall Release() override;
|
||||
|
||||
// [IDropTarget]
|
||||
// [Windows::IDropTarget]
|
||||
Windows::HRESULT __stdcall DragEnter(Windows::IDataObject* pDataObj, Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect) override;
|
||||
Windows::HRESULT __stdcall DragOver(Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect) override;
|
||||
Windows::HRESULT __stdcall DragLeave() override;
|
||||
|
||||
Reference in New Issue
Block a user