2024-03-18 15:41:46 -03:00
|
|
|
#ifndef XNA_PLATFORM_WINDOW_DX_HPP
|
|
|
|
#define XNA_PLATFORM_WINDOW_DX_HPP
|
|
|
|
|
|
|
|
#include "../game/window.hpp"
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
|
|
|
namespace xna {
|
|
|
|
|
|
|
|
enum class GameWindowMode : UINT {
|
|
|
|
Fullscreen = WS_POPUP | WS_VISIBLE,
|
|
|
|
Windowed = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE,
|
|
|
|
Borderless = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,
|
|
|
|
};
|
|
|
|
|
2024-03-21 16:01:47 -03:00
|
|
|
class GameWindow : public IGameWindow {
|
2024-03-18 15:41:46 -03:00
|
|
|
public:
|
2024-03-21 16:01:47 -03:00
|
|
|
GameWindow();
|
2024-03-18 15:41:46 -03:00
|
|
|
|
|
|
|
constexpr void Mode(GameWindowMode mode) {
|
|
|
|
_windowStyle = static_cast<int>(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr GameWindowMode Mode() const {
|
|
|
|
return static_cast<GameWindowMode>(_windowStyle);
|
|
|
|
}
|
|
|
|
|
2024-03-30 14:25:08 -03:00
|
|
|
void Position(int width, int height, bool update = true);
|
|
|
|
void Size(int width, int height, bool update = true);
|
2024-03-18 15:41:46 -03:00
|
|
|
|
|
|
|
inline HINSTANCE HInstance() const {
|
|
|
|
return _hInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline HWND WindowHandle() const {
|
|
|
|
return _windowHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Width() const {
|
|
|
|
return _windowWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Height() const {
|
|
|
|
return _windowHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Icon(unsigned int icon) {
|
|
|
|
_windowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Icon(HICON icon) {
|
|
|
|
_windowIcon = icon;
|
|
|
|
}
|
2024-03-21 16:01:47 -03:00
|
|
|
|
2024-03-18 15:41:46 -03:00
|
|
|
inline void Cursor(unsigned int cursor) {
|
|
|
|
_windowCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(cursor));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Cursor(HCURSOR cursor) {
|
|
|
|
_windowCursor = cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float CenterX() const {
|
|
|
|
return _windowCenterX;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float CenterY() const {
|
|
|
|
return _windowCenterY;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void CursorVisibility(bool visible) const {
|
|
|
|
ShowCursor(visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Close() {
|
|
|
|
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline COLORREF Color() const {
|
|
|
|
return _windowColor;
|
|
|
|
}
|
|
|
|
|
2024-03-21 16:01:47 -03:00
|
|
|
inline void Color(COLORREF color) {
|
2024-03-18 15:41:46 -03:00
|
|
|
_windowColor = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Color(BYTE r, BYTE g, BYTE b) {
|
|
|
|
_windowColor = RGB(r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create();
|
2024-03-30 14:25:08 -03:00
|
|
|
bool Update();
|
|
|
|
|
2024-03-18 15:41:46 -03:00
|
|
|
static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2024-03-21 16:01:47 -03:00
|
|
|
virtual String Title() const override;
|
|
|
|
virtual void Title(String const& title) override;
|
|
|
|
virtual Rectangle ClientBounds() const override;
|
|
|
|
virtual intptr_t Handle() const override;
|
|
|
|
|
|
|
|
private:
|
2024-03-18 15:41:46 -03:00
|
|
|
HINSTANCE _hInstance{ nullptr };
|
|
|
|
HWND _windowHandle{ nullptr };
|
|
|
|
int _windowWidth{ 800 };
|
|
|
|
int _windowHeight{ 600 };
|
|
|
|
HICON _windowIcon{ nullptr };
|
|
|
|
HCURSOR _windowCursor{ nullptr };
|
|
|
|
COLORREF _windowColor{ RGB(0,0,0) };
|
|
|
|
String _windowTitle{ "Xna++ Game Development" };
|
|
|
|
DWORD _windowStyle{ 0 };
|
|
|
|
int _windowPosX{ 0 };
|
|
|
|
int _windowPosY{ 0 };
|
|
|
|
float _windowCenterX{ 0 };
|
|
|
|
float _windowCenterY{ 0 };
|
|
|
|
|
|
|
|
private:
|
|
|
|
inline void setPosition() {
|
|
|
|
_windowPosX = GetSystemMetrics(SM_CXSCREEN) / 2 - _windowWidth / 2;
|
|
|
|
_windowPosY = GetSystemMetrics(SM_CYSCREEN) / 2 - _windowHeight / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setCenter() {
|
|
|
|
_windowCenterX = _windowWidth / 2.0f;
|
|
|
|
_windowCenterY = _windowHeight / 2.0f;
|
2024-03-21 16:01:47 -03:00
|
|
|
}
|
2024-03-18 15:41:46 -03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|