mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em GameWindow
This commit is contained in:
parent
c686c38100
commit
5316882cf5
@ -109,6 +109,19 @@ namespace xna {
|
|||||||
void GraphicsDeviceManager::ChangeDevice() {
|
void GraphicsDeviceManager::ChangeDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsDeviceManager::ChangeDevice(bool forceCreate) {
|
||||||
|
if (!game)
|
||||||
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
|
|
||||||
|
inDeviceTransition = true;
|
||||||
|
auto screenDeviceName = game->Window()->ScreenDeviceName();
|
||||||
|
int clientWidth = game->Window()->ClientBounds().Width;
|
||||||
|
int clientHeight = game->Window()->ClientBounds().Height;
|
||||||
|
bool flag1 = false;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsDeviceManager::AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
void GraphicsDeviceManager::AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
||||||
const auto handle = game->Window()->Handle();
|
const auto handle = game->Window()->Handle();
|
||||||
|
|
||||||
|
@ -2,20 +2,17 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
GameWindow::GameWindow() {
|
GameWindow::GameWindow() {
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>(this);
|
||||||
|
|
||||||
impl->_hInstance = GetModuleHandle(NULL);
|
impl->_hInstance = GetModuleHandle(NULL);
|
||||||
impl->_windowIcon = LoadIcon(NULL, IDI_APPLICATION);
|
impl->_windowIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
impl->_windowCursor = LoadCursor(NULL, IDC_ARROW);
|
impl->_windowCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
impl->_windowStyle = static_cast<int>(GameWindowMode::Windowed);
|
impl->_windowStyle = static_cast<int>(GameWindowMode::Windowed);
|
||||||
impl->_windowCenterX = impl->_windowWidth / 2.0F;
|
impl->_windowCenterX = impl->_windowWidth / 2.0F;
|
||||||
impl->_windowCenterY = impl->_windowHeight / 2.0F;
|
impl->_windowCenterY = impl->_windowHeight / 2.0F;
|
||||||
|
impl->_windowWidth = GameWindow::DefaultClientWidth;
|
||||||
}
|
impl->_windowHeight = GameWindow::DefaultClientHeight;
|
||||||
|
}
|
||||||
GameWindow::~GameWindow() {
|
|
||||||
impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWindow::PlatformImplementation::Position(int width, int height, bool update) {
|
void GameWindow::PlatformImplementation::Position(int width, int height, bool update) {
|
||||||
_windowPosX = width;
|
_windowPosX = width;
|
||||||
@ -34,9 +31,8 @@ namespace xna {
|
|||||||
if(update) Update();
|
if(update) Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWindow::Title(String const& title) {
|
void GameWindow::Title(String const& value) {
|
||||||
if (!impl) return;
|
title = value;
|
||||||
|
|
||||||
impl->_windowTitle = title;
|
impl->_windowTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +88,29 @@ namespace xna {
|
|||||||
return _windowHandle ? true : false;
|
return _windowHandle ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// GameWindow
|
||||||
|
//
|
||||||
|
|
||||||
|
gameWindow->handle = reinterpret_cast<intptr_t>(_windowHandle);
|
||||||
|
gameWindow->title = _windowTitle;
|
||||||
|
gameWindow->clientBounds = { _windowPosX, _windowPosY, _windowWidth, _windowHeight };
|
||||||
|
gameWindow->currentOrientation = DisplayOrientation::Default;
|
||||||
|
|
||||||
|
auto screens = Screen::AllScreens();
|
||||||
|
|
||||||
|
if (screens.size() == 1)
|
||||||
|
gameWindow->screenDeviceName = screens[0]->DeviceName();
|
||||||
|
else {
|
||||||
|
for (size_t i = 0; i < screens.size(); ++i) {
|
||||||
|
const auto& screen = screens[i];
|
||||||
|
|
||||||
|
if (screen->Primary())
|
||||||
|
gameWindow->screenDeviceName = screen->DeviceName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,30 +137,13 @@ namespace xna {
|
|||||||
return _windowHandle ? true : false;
|
return _windowHandle ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameWindow->clientBounds = { _windowPosX, _windowPosY, _windowWidth, _windowHeight };
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GameWindow::Title() const {
|
bool GameWindow::IsWindowMinimized() const {
|
||||||
if (!impl) return String();
|
return IsIconic(impl->_windowHandle);
|
||||||
|
|
||||||
return impl->_windowTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle GameWindow::ClientBounds() const {
|
|
||||||
if (!impl) return {};
|
|
||||||
|
|
||||||
return Rectangle(
|
|
||||||
impl->_windowPosX,
|
|
||||||
impl->_windowPosY,
|
|
||||||
impl->_windowWidth,
|
|
||||||
impl->_windowHeight
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
intptr_t GameWindow::Handle() const {
|
|
||||||
if (!impl) return 0;
|
|
||||||
|
|
||||||
return reinterpret_cast<intptr_t>(impl->_windowHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT GameWindow::PlatformImplementation::WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT GameWindow::PlatformImplementation::WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
@ -242,4 +244,9 @@ namespace xna {
|
|||||||
|
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String GameWindow::ScreenDeviceName() const {
|
||||||
|
//TODO
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
}
|
}
|
@ -168,7 +168,6 @@ namespace xna {
|
|||||||
class Effect;
|
class Effect;
|
||||||
class GraphicsAdapter;
|
class GraphicsAdapter;
|
||||||
class GraphicsDevice;
|
class GraphicsDevice;
|
||||||
class GraphicsDeviceInformation;
|
|
||||||
struct PresentationParameters;
|
struct PresentationParameters;
|
||||||
class RenderTarget2D;
|
class RenderTarget2D;
|
||||||
class SwapChain;
|
class SwapChain;
|
||||||
|
@ -139,12 +139,8 @@ namespace xna {
|
|||||||
//Applies any changes to device-related properties, changing the graphics device as necessary.
|
//Applies any changes to device-related properties, changing the graphics device as necessary.
|
||||||
void ApplyChanges();
|
void ApplyChanges();
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
bool ToggleFullScreen();
|
bool ToggleFullScreen();
|
||||||
|
|
||||||
private:
|
|
||||||
void ChangeDevice(bool forceCreate){}
|
|
||||||
void AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
|
||||||
void AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateDevice();
|
void CreateDevice();
|
||||||
@ -159,6 +155,10 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ChangeDevice(bool forceCreate);
|
||||||
|
void AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
||||||
|
void AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) const;
|
||||||
|
|
||||||
bool BeginDraw() override { return false; }
|
bool BeginDraw() override { return false; }
|
||||||
void EndDraw() override{ }
|
void EndDraw() override{ }
|
||||||
|
|
||||||
@ -184,6 +184,7 @@ namespace xna {
|
|||||||
Int resizedBackBufferWidth{ 0 };
|
Int resizedBackBufferWidth{ 0 };
|
||||||
Int resizedBackBufferHeight{ 0 };
|
Int resizedBackBufferHeight{ 0 };
|
||||||
bool allowMultiSampling{ false };
|
bool allowMultiSampling{ false };
|
||||||
|
bool inDeviceTransition{ false };
|
||||||
|
|
||||||
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
||||||
};
|
};
|
||||||
|
@ -9,14 +9,47 @@ namespace xna {
|
|||||||
class GameWindow {
|
class GameWindow {
|
||||||
public:
|
public:
|
||||||
GameWindow();
|
GameWindow();
|
||||||
~GameWindow();
|
|
||||||
String Title() const;
|
//Gets the current display orientation, which reflects the physical orientation of the phone in the user's hand.
|
||||||
void Title(String const& title);
|
constexpr DisplayOrientation CurrentOrientation() const {
|
||||||
Rectangle ClientBounds() const;
|
return currentOrientation;
|
||||||
intptr_t Handle() const;
|
}
|
||||||
|
|
||||||
|
//Gets and sets the title of the system window.
|
||||||
|
constexpr String Title() const {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Gets and sets the title of the system window.
|
||||||
|
void Title(String const& value);
|
||||||
|
|
||||||
|
//Gets the handle to the system window.
|
||||||
|
constexpr intptr_t Handle() const {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The screen dimensions of the game window's client rectangle.
|
||||||
|
constexpr Rectangle ClientBounds() const {
|
||||||
|
return clientBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Gets the device name of the screen the window is currently in.
|
||||||
|
String ScreenDeviceName() const;
|
||||||
|
|
||||||
static uptr<Screen> ScreenFromAdapter(GraphicsAdapter const& adapter);
|
static uptr<Screen> ScreenFromAdapter(GraphicsAdapter const& adapter);
|
||||||
static uptr<Screen> ScreenFromHandle(intptr_t windowHandle);
|
static uptr<Screen> ScreenFromHandle(intptr_t windowHandle);
|
||||||
|
bool IsWindowMinimized() const;
|
||||||
|
|
||||||
|
inline static constexpr Int DefaultClientWidth = 800;
|
||||||
|
inline static constexpr Int DefaultClientHeight = 600;
|
||||||
|
|
||||||
|
private:
|
||||||
|
String title;
|
||||||
|
intptr_t handle{ 0 };
|
||||||
|
Rectangle clientBounds{};
|
||||||
|
String screenDeviceName;
|
||||||
|
DisplayOrientation currentOrientation{ DisplayOrientation::Default };
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
|
@ -698,6 +698,8 @@ namespace xna {
|
|||||||
|
|
||||||
struct GameWindow::PlatformImplementation {
|
struct GameWindow::PlatformImplementation {
|
||||||
public:
|
public:
|
||||||
|
PlatformImplementation(GameWindow* gameWindow): gameWindow(gameWindow){}
|
||||||
|
|
||||||
constexpr void Mode(GameWindowMode mode) {
|
constexpr void Mode(GameWindowMode mode) {
|
||||||
_windowStyle = static_cast<int>(mode);
|
_windowStyle = static_cast<int>(mode);
|
||||||
}
|
}
|
||||||
@ -776,6 +778,7 @@ namespace xna {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GameWindow;
|
friend class GameWindow;
|
||||||
|
GameWindow*& gameWindow;
|
||||||
|
|
||||||
HINSTANCE _hInstance{ nullptr };
|
HINSTANCE _hInstance{ nullptr };
|
||||||
HWND _windowHandle{ nullptr };
|
HWND _windowHandle{ nullptr };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user