Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenix3 committed Jan 7, 2025
1 parent 64f9c51 commit af82cca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 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,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);

Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down
23 changes: 8 additions & 15 deletions src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions src/graphic/Fast3D/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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;
Expand All @@ -243,7 +242,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 @@ -259,7 +258,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 @@ -533,7 +532,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

0 comments on commit af82cca

Please sign in to comment.