mirror of
https://github.com/izzy2lost/libultraship.git
synced 2026-06-19 01:16:13 -07:00
Run clang-format
This commit is contained in:
@@ -62,8 +62,7 @@ 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);
|
||||
|
||||
@@ -163,7 +162,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() {
|
||||
@@ -182,7 +181,8 @@ 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);
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -149,24 +149,21 @@ 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) {
|
||||
@@ -368,8 +365,7 @@ 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);
|
||||
@@ -378,8 +374,7 @@ 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);
|
||||
@@ -458,8 +453,7 @@ 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:
|
||||
@@ -529,8 +523,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,6 @@ 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;
|
||||
@@ -244,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());
|
||||
}
|
||||
@@ -260,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);
|
||||
@@ -534,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());
|
||||
}
|
||||
|
||||
+2
-1
@@ -49,7 +49,8 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user