Public: anyone can read this; the crew can change it.

forked from trevato/cs

cant buy. im trying to buy but when i hit b the menu opens and my mouse is st… #420

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Fixes #355: while the buy menu is open, you can now click to buy with the mouse. Since #274 the menu keeps the mouse locked to the game so the number keys can buy without leaving it. A locked mouse has no visible cursor and can't click, so the tiles couldn't be clicked.

shipped production is serving it deploy ae07c2d

opened this

Fixes #355: while the buy menu is open, you can now click to buy with the mouse. Since #274 the menu keeps the mouse locked to the game so the number keys can buy without leaving it. A locked mouse has no visible cursor and can't click, so the tiles couldn't be clicked.

While the menu is open and the mouse is locked, the menu now draws its own pointer:

  • Moving: the mouse moves the pointer instead of turning your view. The pointer stops at the menu's edge.
  • Clicking: a left click presses the tile under the pointer, the same as a real click on it would. A greyed-out tile or empty space buys nothing.

The number keys, X (rebuy), tapping on a phone and Tab from the keyboard work as before. Closing the menu gives the mouse back to your view.

Why #358 failed its check: this is the same change, now merged with a main that has moved on 129 commits. #358's check failed because the game's JavaScript bundle went over its size limit: main had 196 gzipped bytes left and the pointer costs 462. Following the rule written in src/games.ts, the limit for app goes up to the size measured with bun run scripts/build.ts plus about five per cent: 140,568 → 147,600 raw and 54,766 → 57,500 gzipped. The reason is recorded next to the number, and scripts/build.test.ts has the same numbers.

What to look at:

  • src/client/cursor.ts holds the pointer's position as plain data.
  • drawBuy in src/client/buy.ts now hands back each button it drew, and controlAt finds which one is under the pointer.
  • src/client/main.ts sends mouse movement to the pointer while the menu is open and the mouse is locked. The merge conflict here was with the radio code from main; both sides are kept.
  • src/pages/game.ts renders a hidden #buycursor on the server and moves it only with transform, so nothing else on the page shifts.
  • src/client/stage.test-helper.ts had a conflict with the new pause settings from main: buycursor is added to main's list of page IDs.

Not done: I didn't go back to releasing the mouse when the menu opens. The player would then have to click the game again to lock it after buying, which is the extra step #274 removed.

Tests: bun run test passes (typecheck plus 1732 tests). cursor.test.ts and buy.test.ts cover the pointer's edges and a dead tile. main.test.ts runs the whole game: open the menu, move the mouse and check the view doesn't turn, click the pistol and check it's bought, then close the menu and check the mouse turns the view again. The app boots and / answers with a 200 in 23 ms. I haven't tried it in a real browser.

To try it in the preview: start a match and press B during freeze time. Moving the mouse moves the pointer while your view stays still; click a tile to buy it.

🤖 Generated with Claude Code

Closes #355

Closes #355

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs