From 31adf3d7af7aec6d5e14faeb5ab8baf81d249be8 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Thu, 25 Sep 2025 09:57:45 +0200 Subject: [PATCH] Formatting --- src/client/client.c | 16 +++++++++------- src/client/gfx_context.c | 12 ++++++------ src/client/gfx_context.h | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/client/client.c b/src/client/client.c index 1d0c365..88e7058 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -100,7 +100,7 @@ SDL_AppEvent (void *appstate, SDL_Event *event) drag_origin_y = gfx_ctx->world_y_offset; } else if (event->type == SDL_EVENT_MOUSE_BUTTON_UP && - event->button.button == SDL_BUTTON_LEFT) + event->button.button == SDL_BUTTON_LEFT) { dragging = false; } @@ -114,7 +114,7 @@ SDL_AppEvent (void *appstate, SDL_Event *event) if (event->type == SDL_EVENT_MOUSE_WHEEL) { - float zoom_factor = 1.0f + (event->wheel.y * 0.1f); /* ±10% per notch */ + float zoom_factor = 1.0f + (event->wheel.y * 0.1f); /* ±10% per notch */ /* Zoom around the mouse cursor */ int win_w, win_h; @@ -123,16 +123,18 @@ SDL_AppEvent (void *appstate, SDL_Event *event) float mouse_x = event->wheel.mouse_x; float mouse_y = event->wheel.mouse_y; - float before_x = (mouse_x - gfx_ctx->world_x_offset) / gfx_ctx->world_scale; - float before_y = (mouse_y - gfx_ctx->world_y_offset) / gfx_ctx->world_scale; + float before_x = + (mouse_x - gfx_ctx->world_x_offset) / gfx_ctx->world_scale; + float before_y = + (mouse_y - gfx_ctx->world_y_offset) / gfx_ctx->world_scale; gfx_ctx->world_scale *= zoom_factor; if (gfx_ctx->world_scale < 0.1f) { - gfx_ctx->world_scale = 0.1f; /* clamp */ + gfx_ctx->world_scale = 0.1f; /* clamp */ } - + if (gfx_ctx->world_scale > 10.0f) { gfx_ctx->world_scale = 10.0f; @@ -143,7 +145,7 @@ SDL_AppEvent (void *appstate, SDL_Event *event) gfx_ctx->world_x_offset = mouse_x - after_x; gfx_ctx->world_y_offset = mouse_y - after_y; - } + } return SDL_APP_CONTINUE; } diff --git a/src/client/gfx_context.c b/src/client/gfx_context.c index f8691a9..5da5067 100644 --- a/src/client/gfx_context.c +++ b/src/client/gfx_context.c @@ -43,7 +43,7 @@ GfxContext_new () } GfxContext_reset (self); - + return self; } @@ -57,12 +57,12 @@ GfxContext_render (GfxContext *self) { float tex_w, tex_h; SDL_GetTextureSize (self->world_texture, &tex_w, &tex_h); - + SDL_FRect dst = { - .x = self->world_x_offset, - .y = self->world_y_offset, - .w = tex_w * self->world_scale, - .h = tex_h * self->world_scale + .x = self->world_x_offset, + .y = self->world_y_offset, + .w = tex_w * self->world_scale, + .h = tex_h * self->world_scale }; SDL_RenderTexture (self->renderer, self->world_texture, NULL, &dst); diff --git a/src/client/gfx_context.h b/src/client/gfx_context.h index 6c0770c..42d8a0d 100644 --- a/src/client/gfx_context.h +++ b/src/client/gfx_context.h @@ -43,7 +43,7 @@ typedef struct GfxContext GfxContext *GfxContext_new (); void GfxContext_render (GfxContext * self); -void GfxContext_reset (GfxContext *self); +void GfxContext_reset (GfxContext * self); void GfxContext_free (GfxContext * self); void GfxContext_cache_World (GfxContext * self, World * world);