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
Check · Review · Land · Live done — Landed and live in production.
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
Sign in to join this conversation.
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:
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
mainthat has moved on 129 commits. #358's check failed because the game's JavaScript bundle went over its size limit:mainhad 196 gzipped bytes left and the pointer costs 462. Following the rule written insrc/games.ts, the limit forappgoes up to the size measured withbun run scripts/build.tsplus about five per cent: 140,568 → 147,600 raw and 54,766 → 57,500 gzipped. The reason is recorded next to the number, andscripts/build.test.tshas the same numbers.What to look at:
src/client/cursor.tsholds the pointer's position as plain data.drawBuyinsrc/client/buy.tsnow hands back each button it drew, andcontrolAtfinds which one is under the pointer.src/client/main.tssends mouse movement to the pointer while the menu is open and the mouse is locked. The merge conflict here was with the radio code frommain; both sides are kept.src/pages/game.tsrenders a hidden#buycursoron the server and moves it only withtransform, so nothing else on the page shifts.src/client/stage.test-helper.tshad a conflict with the new pause settings frommain:buycursoris added tomain'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 testpasses (typecheck plus 1732 tests).cursor.test.tsandbuy.test.tscover the pointer's edges and a dead tile.main.test.tsruns 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