Commit Graph

9 Commits

Author SHA1 Message Date
1ddb532325 Fix ally/target bugs, OCR fire-support parsing, add debug capture
- Board.clear() now also drops allies; the "clear board?" guard checks
  allies too. New Board.clear_units() + Clear button right-click menu
  ("clear enemies, units & flights", keeps Nest/spotters/RPs).
- An Ally with the ad-hoc TargetType.ENEMY showed "Enemy" on the map
  popover/toast instead of "Ally" (icons.target_type_label already had
  the fix for the picker, now reused everywhere else via app.py's
  _display_name).
- Firing panel drag-reorder no longer triggers a full app refresh
  (solver + dedupe + map redraw) on every drop, just a local rebuild.
- "Always show geo" didn't draw for Allies (missing from the overlay
  candidate list); blast radius only respected selection, not the
  show_geo_desc pin.
- ocr.py: added a second fire-support-request grammar ("Infantry#N
  taking fire ... Requesting X Shell on our position at <coord> before
  <time>", plus a bearing/distance-from-position variant), distinct
  from the existing Marine Garrison one.
- New debug_capture.py: saves screenshots (+ metadata) the app handled
  badly, for later tuning of map_vision/ocr against real failures:
  map-read errors, user grid corrections (paired with the auto-detected
  grid), screenshots that read as text but may have been a map, and
  marker-detection ground truth (every proposal's accept/reject verdict
  plus units added with no matching proposal) captured whenever a
  screenshot stops being the active one.
- README: Known issues section (map screenshot reading, grid + unit
  detection, is unreliable and fails often).
- 14 new tests (tests/test_models.py, tests/test_debug_capture.py, +
  additions to tests/test_ocr.py), 38/38 passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-11 17:35:37 +02:00
e585fc5428 Map: square-cell toggle and scroll-wheel zoom
Refactored GridCanvas's geometry around a single _View namedtuple
(cell_w/cell_h/grid_w/grid_h/pad_x/pad_y/viewport origin/visible
extent) instead of threading cell_w/cell_h/grid_h separately through
every draw and hit-test method, that's what makes the two new features
below tractable without a parameter explosion.

- Square-cell toggle (header button, 'view-grid-symbolic'): forces
  cell_w == cell_h, letterboxing (padding) whichever axis has leftover
  space instead of stretching cells to fill the widget. Off by default,
  recovers the exact previous stretch-to-fill behavior.
- Scroll-wheel zoom: 1x (the whole 20x10 map, the old fixed behavior)
  up to 10x, anchored at the cursor's last known position so the km
  point under it stays under it as the zoom level changes, panned/
  clamped so the viewport never hangs off the grid's edge. Grid lines,
  column/row labels, and every marker only draw for the visible
  viewport, not always the full 20x10 grid.

Also two bugs found and fixed along the way:
- The header's cursor-location readout showed AZ/distance-from-nest
  numbers even when the cursor was off the map entirely:
  bearing_deg_point()/distance_km_point() are happy to compute on any
  raw km point, on- map or not, only the coord label itself checked
  bounds. Now the whole readout is just 'off map' whenever the cursor
  genuinely isn't over the grid.
- That bounds check initially reused solver.point_to_coord()'s own
  tolerance, which deliberately forgives up to 0.5km past an edge
  (rounding slop for noisy OCR'd coordinates), the wrong call for 'is
  the mouse over the map', a cursor visibly off the drawn grid still
  passed it. The cursor readout now uses a strict 0<=col<=COLS/
  0<=row<=ROWS check instead.

Verified with GTK smoke tests: zoom in/out and pan-anchoring math,
square-cell letterboxing padding, hover/hit-testing, the toggle wired
end-to-end through the real header button, and the full app launching
and surviving the exact scenario that crashed it earlier in this same
session (an incomplete mid-refactor commit referenced _on_scroll before
it was defined, caught immediately by re-running the app, fixed by
finishing the refactor properly instead of patching around it).

Also, on the firing card: swapped the shell icon to come after the
powder-charge segments instead of before (per feedback), and gave the
assignment cycle button (L/R/-) the same 'image-button' style class its
icon-only siblings get automatically, it was visibly wider than them
for carrying a text label instead of an icon.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 19:43:35 +02:00
bcfa995417 Bump charge-segment size now that its CSS rule actually applies
The previous 20px min-width/height looked like a regression (smaller
than before) once the button.<class> selector fix actually started
taking effect: before that fix, the rule was being silently ignored
entirely and the theme's own (bigger) default button min-size was what
users were actually seeing by accident. Now that the rule genuinely
applies, bumped to 28px, verified directly against the real allocated
widget size (28x28), not just the requested CSS value.
2026-08-09 19:31:03 +02:00
3b209e743e Shell icon picker: fix real sizing bugs, crop icon padding, inline grid for Add Strike
Several rounds of actually looking at the running app instead of just
the code, in order:

- The icon-only shell button on a firing card, and the popover-based
  picker, both fought a genuine GTK sizing quirk: Gtk.Picture's natural
  size is the source image's full native resolution (512x256) no
  matter what set_size_request() says, so the button's own requested
  size swung unpredictably depending on layout context (sometimes
  comically wide, sometimes squeezed tiny). Fixed by pre-scaling the
  actual pixel data with GdkPixbuf first (preserving real aspect ratio)
  and wrapping the already-correctly-sized result, nothing left for
  the surrounding layout to guess about.
- The shell icon PNGs themselves carry a lot of built-in transparent
  padding around the actual artwork. Cropped all of them (except MSTD,
  see below) to the same shared bounding box, computed as the union of
  every file's real content so nothing gets clipped and every icon
  stays aligned the same way.
- MSTD (mustard/YX blister agent) removed from the Shell enum entirely:
  its own game icon is stamped 'UNAVAILABLE IN DEMO', it isn't actually
  a real selectable shell in the game.
- Extra empty chrome around icon-only buttons turned out to be GTK CSS
  specificity, not a missing property: GTK's CSS has no !important at
  all (confirmed, its parser rejects it outright), and separately,
  Gtk.MenuButton's CSS node is literally named 'menubutton', not
  'button', so a 'button.<class>' selector silently matched zero
  elements on it. The actual leftover padding lives on MenuButton's
  internal child button node, reached with a child-combinator selector
  ('menubutton.<class> > button').
- The Add Strike dialog's shell picker is now an inline radio-style
  grid (build_shell_grid(), Gtk.ToggleButton.set_group()) instead of a
  button that opens a submenu popover: it's a 'pick one before
  proceeding' dialog with room to just show every option up front,
  hiding them behind an extra click didn't earn anything. The firing
  card and its tighter row still use the popover version.
- Grid is 3 columns (was 4), sized bigger now that padding is real
  content, not just empty canvas.

Also two unrelated but real bugs found and fixed while chasing this,
from actually reproducing what screenshots showed instead of taking
them as pure cosmetic complaints:
- Selecting a firing card shifted every icon/label inside it inward by
  2px: only .firing-card-selected had a border, unselected cards had
  none at all, so gaining a border on selection shifted the box's
  content instead of just changing a color. Border is now reserved at
  the same width on every card, always, selection only changes its
  color from transparent.
- Changing a target's powder charge visibly shifted the whole card:
  the charge segment buttons had no valign, so once the row got taller
  (the bigger shell icon next to them), they silently inherited the
  default FILL alignment and stretched into ovals instead of staying a
  fixed circle. They also relied on plain 'flat'/'suggested-action' for
  their off/on look, which draws no border at all when off, making an
  unselected segment invisible against the card background. Both fixed
  with a dedicated fixed-size, always-outlined CSS class and explicit
  valign/halign=CENTER.
- The AZ column's screen position depended on the ELEV value's digit
  count (elevation recalculates per charge picked), fixed with a
  reserved width_chars on the elevation label.

Verified at each step by actually rendering the affected widget/dialog/
card to a PNG and looking at it (including a real FiringPanel card
before/after a charge change, pixel-diffed to confirm nothing but the
intended fill state moved), not by reasoning about the code alone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 19:28:41 +02:00
a8f77b98cb Fix the shell icon picker: real icon size, grid layout, no horizontal scroll
Three real bugs from the first pass, all from actually looking at the
running app instead of just the code:

- Icons rendered tiny regardless of source resolution: Gtk.Image caps
  displayed size to GTK's icon-size classes (built for symbolic
  16/32px icons) no matter what you load into it. Switched to
  Gtk.Picture, which sizes by the image's real dimensions.
- The popover's plain vertical list of rows squeezed down to a near-
  unreadable width: ScrolledWindow sizes to its content's minimum, not
  natural, size unless told otherwise, and a wrapping description
  label's minimum width can shrink to almost nothing. Replaced with a
  FlowBox grid (icon + blast radius under it, full description as a
  tooltip) with an explicit natural width.
- That grid's column count was pinned to a fixed minimum, so a
  popover that didn't have the room for that many columns overflowed
  sideways and grew a horizontal scrollbar. min_children_per_line
  dropped to 1 (lets it reflow to fewer columns instead) plus
  hscrollbar_policy=NEVER as a hard backstop, not everyone has a
  horizontal scroll wheel.

Also: the firing card's shell button now shows the icon alone (it
already has the shell's short code baked in, a text label next to it
was redundant on an already-tight row), sized to 64px wide/32px tall
to actually be legible, and a new small CSS rule trims the excess
button chrome around an icon-only face so the button isn't visibly
much larger than the icon it holds.
2026-08-09 19:06:56 +02:00
2b73a96c7a Replace the plain-text shell dropdown/list with an icon picker
Both places the app asks for a shell (the Add Strike dialog's
Adw.ComboRow, and the firing panel's per-target shell popover) used to
show just the bare enum name in a plain list, nothing conveying what
the shell actually is. New icons.py builds a shared MenuButton +
popover from the game's own shell icon set (assets/icons/shells/,
already named to match Shell.name exactly): each row shows the shell's
icon, name, description, and blast radius, and the button face updates
to match whichever one gets picked.

Verified via a GTK smoke test that the button and its popover build and
open without crashing.
2026-08-09 18:59:50 +02:00
19e9ffdd68 Fix firing panel scrollbar layout jitter and strike reorder lock-in
Scrollbar: the ScrolledWindow left horizontal policy on AUTOMATIC (the
default), so a vertical scrollbar's own width could shrink the
content area enough to trigger a horizontal scrollbar too, perturbing
card heights and tripping vertical scrolling that wasn't actually
needed. Pinned horizontal off outright, this is a fixed-width sidebar,
never wanted anyway.

Reorder: the card sort key forced every Strike above every non-Strike
on *every* refresh, not just at creation, silently undoing any manual
drag-reorder that moved a strike below other targets. The 'new
strikes go first' behavior only needs to happen once, at creation
(already handled by _add_strike_at's reorder_target(target, 0)); the
sort key was redundant with that and actively fighting the user
afterward. Removed it.
2026-08-09 15:46:22 +02:00
ba6b07a476 Sweep em-dashes out of code, docstrings, and requirements.txt
Same style fix applied to the README earlier, extended everywhere:
replaced " -- " with commas/colons/periods (picking whichever reads
right per occurrence, splitting into two sentences where the clauses
were independent), fixed a few user-facing strings along the way
(entity list rows, placement/strike toasts, ambiguous-candidate tag,
shell picker button label). Left three intentional non-prose uses
alone: the "unassigned" dash glyph in firing_panel.py (and its
docstring diagram), and ocr.py's dash-variant regex character class,
which needs to literally match em/en-dashes in OCR'd text.

Also caught and fixed a stale models.py docstring claiming "no solver
yet" (solver.py has existed for a while) while touching that
paragraph anyway, and a formatting artifact in coord_dialog.py's
docstring left by the sed pass (misaligned comma from a since-removed
alignment gap).

Verified: py_compile across all files, the 9-screenshot OCR
regression sweep, and a GTK smoke test exercising the edited
toast/placement code paths.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-08 20:27:53 +02:00
7ecda4ea3b Rename package/app to FeNigma consistently
- src/ironnest_assist/ -> src/fenigma/
- run.sh invokes -m fenigma.app
- APP_ID: eu.dominik-roth.IronNestAssist -> eu.dominik-roth.FeNigma
- window title, IronNestApp class -> FeNigmaApp
- __init__.py docstring, README pgrep hint updated

IRON NEST (the game's own name, e.g. NEST_KEYWORD in ocr.py) is left
untouched, only our own project/app naming changed. Verified: clean
import under the new module path, install.sh still builds the venv
correctly, and the OCR regression sweep (9 known screenshots) still
passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-08 20:20:43 +02:00