Skip to content

fix: stabilize client box overlay and selection outline#195

Merged
majestyotbr merged 6 commits into
opentibiabr:mainfrom
vllsystems:fix-client-box-and-shift-selection
Jun 8, 2026
Merged

fix: stabilize client box overlay and selection outline#195
majestyotbr merged 6 commits into
opentibiabr:mainfrom
vllsystems:fix-client-box-and-shift-selection

Conversation

@vllsystems

@vllsystems vllsystems commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Fix two long-standing rendering issues in editor overlays:

  • The "Show client box" overlay now stays anchored to the viewport center across pan/zoom, with consistent visible/buffer framing and a correctly centered player tile marker.
  • The dashed selection rectangle (Shift+drag) now renders reliably at zoom-out levels (< 100% UI zoom), keeping all four edges visible by normalizing the rectangle geometry and scaling the stipple thickness/spacing with zoom.

Details

Client box overlay

  • Reworked the ingame client box overlay so its geometry is computed in viewport space (screen/ortho coordinates) instead of tile-aligned map coordinates.
  • Ensures the overlay does not "jump" when zoom changes or when scrolling the map.
  • Recomputed the visible area and player marker from the viewport center to avoid the previous asymmetric offsets.

Selection dashed outline

  • Normalized selection bounds to a stable left/right/top/bottom rectangle regardless of drag direction.
  • Clamped the selection rectangle to the viewport to avoid edge clipping artifacts.
  • Scaled stipple line width and dash spacing with zoom so the right/bottom edges remain visible when zoomed out.

Files changed

  • source/map_drawer.cpp

HOW TO TEST

Client box

  1. Enable View -> Show client box.
  2. Pan/scroll around the map and change zoom levels (including zoom out below 100%).
  3. Confirm the overlay stays fixed at the viewport center (no drifting/jumping).
  4. Confirm the visible/buffer rectangles remain centered and the player tile marker is centered.

Selection outline

  1. Enter selection mode.
  2. Hold Shift and drag a selection rectangle.
  3. Test at 100%, 75%, 50%, 25% zoom (zoom out).
  4. Confirm the dashed outline shows all four sides (right and bottom edges do not disappear).
  5. Drag in all directions (top-left, top-right, bottom-left, bottom-right) and confirm behavior stays consistent.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed in-game map box positioning and viewport clamping so the map centers reliably during pan/zoom.
    • Selection box now clamps to the visible viewport, supports reverse-dragging, and normalizes rectangle coordinates.
    • Selection outline rendering scales with zoom so line width and dash pattern remain consistent.
    • Improved player marker, visible-region highlighting, and overlay styling for clearer map visualization.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b2fdfd84-9f65-4e16-af4c-dc482155ae06

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7c964 and b5e09c6.

📒 Files selected for processing (1)
  • source/map_drawer.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/map_drawer.cpp

📝 Walkthrough

Walkthrough

Two viewport-centric rendering updates in source/map_drawer.cpp: DrawIngameBox now sizes and clamps the client-map box from screen dimensions and zoom, and DrawSelectionBox clamps drag endpoints and scales stippled selection styling with zoom.

Changes

Viewport Rendering Updates

Layer / File(s) Summary
Ingame box viewport-based redesign
source/map_drawer.cpp (lines 525–593)
DrawIngameBox derives geometry from screensize_x/y and zoom, centers the client box in the viewport, clamps side overlays to viewport bounds, and draws three centered outlines: outer client box (green), inner visible-tiles inset (red), and a centered single-tile player marker (red).
Selection box viewport clamping and zoom scaling
source/map_drawer.cpp (lines 723–763)
DrawSelectionBox clamps cursor and last-click endpoints to [0, viewport_size-1] in zoom-scaled pixels, normalizes rectangle corners using min/max ordering for reverse drags, constructs rectangle vertices from L/R/T/B, and sets stippled line width and dash factor based on zoom instead of fixed values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hop across pixels, lines now true,
Viewport-born boxes centered in view.
Selection dashes stretch with every zoom,
Green and red outlines hold the room.
A little rabbit cheers the polished bloom.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix: stabilize client box overlay and selection outline' directly and clearly summarizes the main changes in the PR: fixes to the client box overlay and selection outline rendering, with a focus on stabilization.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
source/map_drawer.cpp

In file included from source/map_drawer.cpp:18:
source/main.h:50:10: fatal error: 'asio.hpp' file not found
50 | #include <asio.hpp>
| ^~~~~~~~~~
1 error generated.
source/map_drawer.cpp:1340:141-1386:1: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'MapDrawer::BlitCreature' in file 'source/map_drawer.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Aborting translation of method 'MapDrawer::BlitCreature' in file 'source/map_drawer.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Aborting translation of method 'MapDrawer::DrawSecondaryMap' in file 'source/map_drawer.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Aborting translation of method 'MapDrawer::DrawMap' in file 'source/map_drawer.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Aborting translation of method 'MapDrawer::Draw' in file 'source/map_drawer.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAs

... [truncated 2200 characters] ...

ntend_decl_funct.add_method.f in file "src/clang/cFrontend_decl.ml", line 48, characters 12-91
Called from ClangFrontend__CFrontend_errors.protect in file "src/clang/cFrontend_errors.ml", line 37, characters 6-10
Re-raised at IStdlib__IExn.reraise_if in file "src/istd/IExn.ml" (inlined), line 18, characters 15-63
Called from ClangFrontend__CFrontend_errors.protect in file "src/clang/cFrontend_errors.ml", line 48, characters 6-141
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl.add_method_if_create_procdesc in file "src/clang/cFrontend_decl.ml" (inlined), line 123, characters 16-158
Called from ClangFrontend__C


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the drawing logic in MapDrawer::DrawIngameBox and MapDrawer::DrawSelectionBox to center elements relative to the viewport, clamp selection coordinates, and scale line rendering with zoom. The reviewer suggests using standard std::clamp instead of manual ternary operators or custom lambdas. Additionally, they recommend removing the unnecessary static intermediate lines array in DrawSelectionBox and directly initializing the verts array to improve thread safety, performance, and readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread source/map_drawer.cpp Outdated
Comment thread source/map_drawer.cpp Outdated
Comment thread source/map_drawer.cpp Outdated
@vllsystems vllsystems force-pushed the fix-client-box-and-shift-selection branch from d75dbf0 to d69a346 Compare June 7, 2026 19:49
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@majestyotbr majestyotbr merged commit e30bd72 into opentibiabr:main Jun 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants