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(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) {
|
||||
const auto handle = game->Window()->Handle();
|
||||
|
||||
|
@ -2,20 +2,17 @@
|
||||
|
||||
namespace xna {
|
||||
GameWindow::GameWindow() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl = unew<PlatformImplementation>(this);
|
||||
|
||||
impl->_hInstance = GetModuleHandle(NULL);
|
||||
impl->_windowIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
impl->_windowCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
impl->_windowStyle = static_cast<int>(GameWindowMode::Windowed);
|
||||
impl->_windowCenterX = impl->_windowWidth / 2.0F;
|
||||
impl->_windowCenterY = impl->_windowHeight / 2.0F;
|
||||
|
||||
}
|
||||
|
||||
GameWindow::~GameWindow() {
|
||||
impl = nullptr;
|
||||
}
|
||||
impl->_windowCenterY = impl->_windowHeight / 2.0F;
|
||||
impl->_windowWidth = GameWindow::DefaultClientWidth;
|
||||
impl->_windowHeight = GameWindow::DefaultClientHeight;
|
||||
}
|
||||
|
||||
void GameWindow::PlatformImplementation::Position(int width, int height, bool update) {
|
||||
_windowPosX = width;
|
||||
@ -34,9 +31,8 @@ namespace xna {
|
||||
if(update) Update();
|
||||
}
|
||||
|
||||
void GameWindow::Title(String const& title) {
|
||||
if (!impl) return;
|
||||
|
||||
void GameWindow::Title(String const& value) {
|
||||
title = value;
|
||||
impl->_windowTitle = title;
|
||||
}
|
||||
|
||||
@ -92,6 +88,29 @@ namespace xna {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -118,30 +137,13 @@ namespace xna {
|
||||
return _windowHandle ? true : false;
|
||||
}
|
||||
|
||||
gameWindow->clientBounds = { _windowPosX, _windowPosY, _windowWidth, _windowHeight };
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String GameWindow::Title() const {
|
||||
if (!impl) return String();
|
||||
|
||||
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);
|
||||
bool GameWindow::IsWindowMinimized() const {
|
||||
return IsIconic(impl->_windowHandle);
|
||||
}
|
||||
|
||||
LRESULT GameWindow::PlatformImplementation::WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
@ -242,4 +244,9 @@ namespace xna {
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
String GameWindow::ScreenDeviceName() const {
|
||||
//TODO
|
||||
return std::string();
|
||||
}
|
||||
}
|
@ -168,7 +168,6 @@ namespace xna {
|
||||
class Effect;
|
||||
class GraphicsAdapter;
|
||||
class GraphicsDevice;
|
||||
class GraphicsDeviceInformation;
|
||||
struct PresentationParameters;
|
||||
class RenderTarget2D;
|
||||
class SwapChain;
|
||||
|
@ -139,12 +139,8 @@ namespace xna {
|
||||
//Applies any changes to device-related properties, changing the graphics device as necessary.
|
||||
void ApplyChanges();
|
||||
bool Initialize();
|
||||
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;
|
||||
bool ToggleFullScreen();
|
||||
|
||||
|
||||
protected:
|
||||
void CreateDevice();
|
||||
@ -159,6 +155,10 @@ namespace xna {
|
||||
}
|
||||
|
||||
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; }
|
||||
void EndDraw() override{ }
|
||||
|
||||
@ -184,6 +184,7 @@ namespace xna {
|
||||
Int resizedBackBufferWidth{ 0 };
|
||||
Int resizedBackBufferHeight{ 0 };
|
||||
bool allowMultiSampling{ false };
|
||||
bool inDeviceTransition{ false };
|
||||
|
||||
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
||||
};
|
||||
|
@ -9,14 +9,47 @@ namespace xna {
|
||||
class GameWindow {
|
||||
public:
|
||||
GameWindow();
|
||||
~GameWindow();
|
||||
String Title() const;
|
||||
void Title(String const& title);
|
||||
Rectangle ClientBounds() const;
|
||||
intptr_t Handle() const;
|
||||
|
||||
//Gets the current display orientation, which reflects the physical orientation of the phone in the user's hand.
|
||||
constexpr DisplayOrientation CurrentOrientation() const {
|
||||
return currentOrientation;
|
||||
}
|
||||
|
||||
//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> 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:
|
||||
struct PlatformImplementation;
|
||||
|
@ -698,6 +698,8 @@ namespace xna {
|
||||
|
||||
struct GameWindow::PlatformImplementation {
|
||||
public:
|
||||
PlatformImplementation(GameWindow* gameWindow): gameWindow(gameWindow){}
|
||||
|
||||
constexpr void Mode(GameWindowMode mode) {
|
||||
_windowStyle = static_cast<int>(mode);
|
||||
}
|
||||
@ -776,6 +778,7 @@ namespace xna {
|
||||
|
||||
private:
|
||||
friend class GameWindow;
|
||||
GameWindow*& gameWindow;
|
||||
|
||||
HINSTANCE _hInstance{ nullptr };
|
||||
HWND _windowHandle{ nullptr };
|
||||
|
Loading…
x
Reference in New Issue
Block a user