diff --git a/src/graphic/Fast3D/Fast3dWindow.cpp b/src/graphic/Fast3D/Fast3dWindow.cpp index e134f464b..798454578 100644 --- a/src/graphic/Fast3D/Fast3dWindow.cpp +++ b/src/graphic/Fast3D/Fast3dWindow.cpp @@ -62,7 +62,8 @@ void Fast3dWindow::Init() { uint32_t width, height; int32_t posX, posY; - isFullscreen = Ship::Context::GetInstance()->GetConfig()->GetBool("Window.Fullscreen.Enabled", 0) || gameMode; + isFullscreen = + Ship::Context::GetInstance()->GetConfig()->GetBool("Window.Fullscreen.Enabled", 0) || gameMode; posX = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.PositionX", 100); posY = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.PositionY", 100); @@ -162,7 +163,7 @@ uint32_t Fast3dWindow::GetWidth() { uint32_t width, height; int32_t posX, posY; mWindowManagerApi->get_dimensions(&width, &height, &posX, &posY); - return width; + return width; } uint32_t Fast3dWindow::GetHeight() { @@ -181,8 +182,7 @@ void Fast3dWindow::SetCurrentDimensions(uint32_t width, uint32_t height) { SetCurrentDimensions(width, height, GetPosX(), GetPosY()); } -void Fast3dWindow::SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, - int32_t posY) { +void Fast3dWindow::SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) { auto conf = Ship::Context::GetInstance()->GetConfig(); if (!isFullscreen) { conf->SetInt("Window.Width", (int32_t)width); diff --git a/src/graphic/Fast3D/gfx_direct3d12.cpp b/src/graphic/Fast3D/gfx_direct3d12.cpp index 85059f11f..441929e1c 100644 --- a/src/graphic/Fast3D/gfx_direct3d12.cpp +++ b/src/graphic/Fast3D/gfx_direct3d12.cpp @@ -183,7 +183,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_descriptor_handle(ComPtrGetCPUDescriptorHandleForHeapStart; void (STDMETHODCALLTYPE ID3D12DescriptorHeap::*fun)(D3D12_CPU_DESCRIPTOR_HANDLE * out) = - (void (STDMETHODCALLTYPE ID3D12DescriptorHeap::*)(D3D12_CPU_DESCRIPTOR_HANDLE * out)) fn; + (void(STDMETHODCALLTYPE ID3D12DescriptorHeap::*)(D3D12_CPU_DESCRIPTOR_HANDLE * out)) fn; D3D12_CPU_DESCRIPTOR_HANDLE handle; (heap.Get()->*fun)(&handle); return handle; @@ -197,7 +197,7 @@ static D3D12_GPU_DESCRIPTOR_HANDLE get_gpu_descriptor_handle(ComPtrGetGPUDescriptorHandleForHeapStart; void (STDMETHODCALLTYPE ID3D12DescriptorHeap::*fun)(D3D12_GPU_DESCRIPTOR_HANDLE * out) = - (void (STDMETHODCALLTYPE ID3D12DescriptorHeap::*)(D3D12_GPU_DESCRIPTOR_HANDLE * out)) fn; + (void(STDMETHODCALLTYPE ID3D12DescriptorHeap::*)(D3D12_GPU_DESCRIPTOR_HANDLE * out)) fn; D3D12_GPU_DESCRIPTOR_HANDLE handle; (heap.Get()->*fun)(&handle); return handle; @@ -212,8 +212,8 @@ static D3D12_RESOURCE_ALLOCATION_INFO get_resource_allocation_info(const D3D12_R auto fn = d3d.device->GetResourceAllocationInfo; void (STDMETHODCALLTYPE ID3D12Device::*fun)(D3D12_RESOURCE_ALLOCATION_INFO * out, UINT visibleMask, UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs) = - (void (STDMETHODCALLTYPE ID3D12Device::*)(D3D12_RESOURCE_ALLOCATION_INFO * out, UINT visibleMask, - UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs)) fn; + (void(STDMETHODCALLTYPE ID3D12Device::*)(D3D12_RESOURCE_ALLOCATION_INFO * out, UINT visibleMask, + UINT numResourceDescs, const D3D12_RESOURCE_DESC* pResourceDescs)) fn; D3D12_RESOURCE_ALLOCATION_INFO out; (d3d.device.Get()->*fun)(&out, 0, 1, resource_desc); return out; diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index 23aded4e0..2db8720b8 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -149,21 +149,24 @@ void UpdateMonitorList() { } else { isPrimary = FALSE; } - + dxgi.monitor_list.push_back({ hmon, mi.rcMonitor, isPrimary }); dxgi.monitor_rects.push_back( - { mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom }); + { mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom} + ); if (isPrimary) { dxgi.primary_monitor_index = dxgi.monitor_rects.size() - 1; } return TRUE; }, - (LPARAM) nullptr); + (LPARAM)nullptr + ); } // Uses coordinates to get a Monitor handle from a list -bool GetMonitorAtCoords(int x, int y, UINT cx, UINT cy, std::tuple& MonitorInfo) { +bool GetMonitorAtCoords(int x, int y, UINT cx, UINT cy, + std::tuple& MonitorInfo) { RECT wr = { x, y, (x + cx), (y + cy) }; std::tuple primary; for (std::tuple i : dxgi.monitor_list) { @@ -365,7 +368,8 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par case WM_SIZE: dxgi.current_width = LOWORD(l_param); dxgi.current_height = HIWORD(l_param); - GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, newMonitor); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, + newMonitor); if (get<0>(newMonitor) != get<0>(dxgi.h_Monitor)) { dxgi.h_Monitor = newMonitor; GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); @@ -374,7 +378,8 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par case WM_MOVE: dxgi.posX = GET_X_LPARAM(l_param); dxgi.posY = GET_Y_LPARAM(l_param); - GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, newMonitor); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, + newMonitor); if (get<0>(newMonitor) != get<0>(dxgi.h_Monitor)) { dxgi.h_Monitor = newMonitor; GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); @@ -453,7 +458,8 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par break; case WM_DISPLAYCHANGE: UpdateMonitorList(); - GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, dxgi.h_Monitor); + GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, + dxgi.h_Monitor); GetMonitorHzPeriod(dxgi.h_Monitor, dxgi.detected_hz, dxgi.display_period); break; case WM_SETFOCUS: @@ -523,7 +529,8 @@ void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_i UpdateMonitorList(); dxgi.posX = posX; dxgi.posY = posY; - if (!GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, dxgi.h_Monitor)) { + if (!GetMonitorAtCoords(dxgi.posX, dxgi.posY, dxgi.current_width, dxgi.current_height, + dxgi.h_Monitor)) { dxgi.posX = 100; dxgi.posY = 100; } diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index b348b9e04..a8eaeb39c 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -223,6 +223,7 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { { SDL_SCANCODE_KP_7, S { SDL_SCANCODE_KP_PERIOD, SDL_SCANCODE_DELETE }, { SDL_SCANCODE_KP_MULTIPLY, SDL_SCANCODE_PRINTSCREEN } }; + static void apply_window_dimensions() { if (fullscreen_state) { SDL_DisplayMode mode; @@ -242,7 +243,7 @@ static void apply_window_dimensions() { if (SDL_SetWindowDisplayMode(wnd, &mode) != 0) { SPDLOG_ERROR("Failed to set SDL Window display Mode: ({})", SDL_GetError()); } - + } else { SPDLOG_ERROR("Failed to get SDL Desktop Display Mode: ({})", SDL_GetError()); } @@ -258,7 +259,7 @@ static void set_fullscreen(bool on, bool call_callback) { } auto conf = Ship::Context::GetInstance()->GetConfig(); - if (!on) { + if (!on) { window_width = conf->GetInt("Window.Width", 640); window_height = conf->GetInt("Window.Height", 480); window_posx = conf->GetInt("Window.PositionX", 100); @@ -532,7 +533,7 @@ static Ship::WindowRect gfx_sdl_get_primary_monitor_rect() { } if (SDL_GetDesktopDisplayMode(display_in_use, &mode) >= 0) { - return { 0, 0, mode.w, mode.h }; + return {0, 0, mode.w, mode.h}; } else { SPDLOG_ERROR("Failed to get SDL Desktop Display Mode: ({})", SDL_GetError()); } diff --git a/src/window/Window.h b/src/window/Window.h index 31ab769b5..9894d57dd 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -49,8 +49,7 @@ class Window { virtual void SetCurrentDimensions(uint32_t width, uint32_t height) = 0; virtual void SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) = 0; virtual void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) = 0; - virtual void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, - int32_t posY) = 0; + virtual void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) = 0; virtual WindowRect GetPrimaryMonitorRect() = 0; virtual int32_t GetPosX() = 0; virtual int32_t GetPosY() = 0;