Skip to content

Commit

Permalink
Revert "Run clang-format"
Browse files Browse the repository at this point in the history
This reverts commit 2e09647.
  • Loading branch information
Kenix3 committed Jan 7, 2025
1 parent b2fc462 commit 64f9c51
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/graphic/Fast3D/Fast3dWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/graphic/Fast3D/gfx_direct3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_descriptor_handle(ComPtr<ID3D12Descri
// pass the address to the return value as a parameter. MinGW32 has the same issue.
auto fn = heap->GetCPUDescriptorHandleForHeapStart;
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;
Expand All @@ -197,7 +197,7 @@ static D3D12_GPU_DESCRIPTOR_HANDLE get_gpu_descriptor_handle(ComPtr<ID3D12Descri
// See get_cpu_descriptor_handle
auto fn = heap->GetGPUDescriptorHandleForHeapStart;
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;
Expand All @@ -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;
Expand Down
23 changes: 15 additions & 8 deletions src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HMONITOR, RECT, BOOL>& MonitorInfo) {
bool GetMonitorAtCoords(int x, int y, UINT cx, UINT cy,
std::tuple<HMONITOR, RECT, BOOL>& MonitorInfo) {
RECT wr = { x, y, (x + cx), (y + cy) };
std::tuple<HMONITOR, RECT, BOOL> primary;
for (std::tuple<HMONITOR, RECT, BOOL> i : dxgi.monitor_list) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/graphic/Fast3D/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
Expand All @@ -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);
Expand Down Expand Up @@ -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());
}
Expand Down
3 changes: 1 addition & 2 deletions src/window/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64f9c51

Please sign in to comment.