Repository navigation
fix(themes): make the bedroom's click areas disjoint and show a covered room on the card #18032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+192
−21
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Fixed | ||
|
|
||
| - A click on the console's right edge also started the tape, and a click where the lava lamp meets the wall light flipped both. The console, the tape's spine and the lava lamp now take clicks over slightly narrower areas, so every click flips one thing. | ||
| - While another plugin's theme covered the room, the settings card still said `theme: on` and its theme button cleared that theme instead of bringing the room back. The card now says `theme: covered` and its button puts the room back; `/bedroom on` does the same, and `/bedroom status` says which plugin's theme covers the room. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // test-scope: plugins/themes/hooks/bedroom/scene/lib.ts plugins/themes/hooks/bedroom/lights.ts | ||
| import assert from 'node:assert/strict' | ||
| import { readFileSync } from 'node:fs' | ||
| import { test } from 'node:test' | ||
|
|
||
| const BEDROOM = new URL('../hooks/bedroom/', import.meta.url) | ||
| const read = path => readFileSync(new URL(path, BEDROOM), 'utf8') | ||
|
|
||
| /** | ||
| * The shader's rows, one per switch column of its buffer: 0 tv, 1 lava, 2 pc, 3 lamp, 4 tape, 5 console, 6 light. | ||
| * lights.ts picks each column's level in that order (v.tv, then v.lava past 0.5, v.pc past 1.5, v.lamp past 2.5, | ||
| * v.light past 5.5), and its screen field units (signals.gen.ts SCREEN: tape 4, console 16) put the tape at 4 and the | ||
| * console at 5. HIT2 is each column's second rectangle, all zeros but the tape's, which is its spine. The cat has no row. | ||
| */ | ||
| const SHADER_ROWS = { | ||
| tv: ['HIT', 0], | ||
| lava: ['HIT', 1], | ||
| pc: ['HIT', 2], | ||
| lamp: ['HIT', 3], | ||
| tape: ['HIT', 4], | ||
| console: ['HIT', 5], | ||
| light: ['HIT', 6], | ||
| spine: ['HIT2', 4], | ||
| } | ||
|
|
||
| function hitsOf(source) { | ||
| const block = /export const HITS[^=]*= \{\n([\s\S]*?)\n\}/.exec(source) | ||
| assert.ok(block, 'scene/lib.ts declares HITS') | ||
| return Object.fromEntries( | ||
| block[1].split('\n').map(line => { | ||
| const row = /^ {2}(\w+): (\[[\d, ]+\]),$/.exec(line) | ||
| assert.ok(row, `a HITS line reads name: [x, y, width, height]: ${line}`) | ||
| return [row[1], JSON.parse(row[2])] | ||
| }), | ||
| ) | ||
| } | ||
|
|
||
| function tableOf(source, name) { | ||
| const line = source.split('\n').find(text => text.startsWith(`const ${name} = table(`)) | ||
| assert.ok(line, `lights.ts declares ${name}`) | ||
| return JSON.parse(line.slice(`const ${name} = table(`.length, -1)) | ||
| } | ||
|
|
||
| test('the shader takes clicks over the same rectangles as HITS', () => { | ||
| const hits = hitsOf(read('scene/lib.ts')) | ||
| const lights = read('lights.ts') | ||
| const tables = { HIT: tableOf(lights, 'HIT'), HIT2: tableOf(lights, 'HIT2') } | ||
|
|
||
| assert.deepEqual(Object.keys(hits).filter(name => name !== 'cat').sort(), Object.keys(SHADER_ROWS).sort(), 'every switch rectangle has a shader row') | ||
| for (const [name, [table, row]] of Object.entries(SHADER_ROWS)) { | ||
| assert.deepEqual(tables[table][row], hits[name], `${name} is ${table} row ${row}`) | ||
| } | ||
| assert.equal(tables.HIT.length, 7, 'HIT has one row per switch column') | ||
| assert.ok( | ||
| tables.HIT2.every((box, row) => row === 4 || box.every(n => n === 0)), | ||
| 'HIT2 holds no rectangle but the spine', | ||
| ) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # test-scope: plugins/themes/hooks/bedroom/scene/lib.ts plugins/themes/hooks/bedroom/lights.ts | ||
| set -uo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| if ! command -v node >/dev/null 2>&1; then | ||
| echo "SKIP: node not installed" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| exec node --test "$SCRIPT_DIR/shader-hits.test.mjs" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.