From c5012ad5996f03f0a4cf8899d8275774e0095068 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Fri, 20 Nov 2026 21:39:18 +0900 Subject: [PATCH 1/4] docs(parts): describe every intrinsic part, and how to set its pins AndN, OrN, 7seg, Display, Input and Output had no description, so the side panel showed no info button for them. Every intrinsic part now has one, which the messages' type requires. A part whose pin widths the player sets also tells that the number in the pin is its bit count, that clicking the pin changes it, and where pins can be added. The descriptions end with a full stop, as some now have several sentences, and Decompose's mirrors Aggregate's. Co-Authored-By: Claude Opus 5.5 --- src/components/PartDescription.test.ts | 34 +++++++++++++++++++++++ src/components/PartDescription.tsx | 30 ++++++++++++++++---- src/i18n/en.ts | 38 ++++++++++++++++++-------- src/i18n/ja.ts | 34 +++++++++++++++-------- 4 files changed, 108 insertions(+), 28 deletions(-) create mode 100644 src/components/PartDescription.test.ts diff --git a/src/components/PartDescription.test.ts b/src/components/PartDescription.test.ts new file mode 100644 index 0000000..f1dd0eb --- /dev/null +++ b/src/components/PartDescription.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, it } from "vitest"; +import { messagesByLanguage } from "../i18n/messages"; +import { + and, + and_n, + broadcast, + decompose, + display, +} from "../store/intrinsics/definitions"; +import { pinNotesOf } from "./PartDescription"; + +const { en, ja } = messagesByLanguage; + +describe("pinNotesOf", () => { + it("tells how to set a pin whose bit width the player chooses", () => { + expect(pinNotesOf(en, broadcast)).toEqual([ + "The number in the Out pin is its number of bits. Click the pin to change it.", + ]); + }); + + it("tells how to add pins where a pin can be split", () => { + expect(pinNotesOf(en, and_n)).toEqual([ + 'The number in the In pin is its number of bits. Click the pin to change it. "Add" adds another In pin.', + ]); + expect(pinNotesOf(ja, decompose)).toEqual([ + "Out のピンの中の数字は、そのピンのビット数。ピンをクリックすると変えられる。「追加」で Out のピンを増やせる。", + ]); + }); + + it("says nothing of pins whose bit widths follow from elsewhere", () => { + expect(pinNotesOf(en, and)).toEqual([]); + expect(pinNotesOf(en, display)).toEqual([]); + }); +}); diff --git a/src/components/PartDescription.tsx b/src/components/PartDescription.tsx index 88c1bf7..afe4d5d 100644 --- a/src/components/PartDescription.tsx +++ b/src/components/PartDescription.tsx @@ -1,20 +1,32 @@ import { Box, Typography } from "@mui/material"; import { type Messages, useMessages } from "../i18n"; import type { CCComponent } from "../store/component"; +import { IntrinsicComponentDefinition } from "../store/intrinsics/base"; import { definitionByComponentId } from "../store/intrinsics/definitions"; import { type TruthTable, truthTableOf } from "../store/intrinsics/truthTable"; import { TruthTableView } from "./TruthTableView"; -type Summaries = Messages["parts"]["summaries"]; - export function partSummary( messages: Messages, component: CCComponent, ): string | null { const type = component.intrinsicType; - return type && type in messages.parts.summaries - ? messages.parts.summaries[type as keyof Summaries] - : null; + return type ? messages.parts.summaries[type] : null; +} + +/** How to set the pins whose bit widths the player chooses, which nothing else tells */ +export function pinNotesOf( + messages: Messages, + definition: IntrinsicComponentDefinition, +): string[] { + return definition.allPins.flatMap((pin) => { + const policy = IntrinsicComponentDefinition.getPinAttributesByPinId( + pin.id, + )?.bitWidthPolicy; + return policy?.type === "configurable" + ? [messages.parts.pinBitWidth(pin.name, policy.isSplittable)] + : []; + }); } export function PartDescription({ component }: { component: CCComponent }) { @@ -24,6 +36,7 @@ export function PartDescription({ component }: { component: CCComponent }) { ); @@ -32,10 +45,12 @@ export function PartDescription({ component }: { component: CCComponent }) { export function PartDescriptionView({ name, summary, + notes = [], table, }: { name: string; summary: string | null; + notes?: readonly string[]; table: TruthTable | null; }) { return ( @@ -48,6 +63,11 @@ export function PartDescriptionView({ {name} {summary && {summary}} + {notes.map((note) => ( + + {note} + + ))} {table && ( diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 1b8e61d..64d941b 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1,3 +1,4 @@ +import type { CCIntrinsicComponentType } from "../store/intrinsics/types"; import { englishSimulationErrorTexts } from "../store/simulationErrorTexts"; import type { TutorialPartId, TutorialStageId } from "../tutorial/stages"; @@ -98,19 +99,32 @@ export const en = { }, parts: { summaries: { - AND: "ON only when both inputs are ON", - OR: "ON when at least one input is ON", - NOT: "Turns ON into OFF, and OFF into ON", - XOR: "ON when exactly one input is ON", - TRUE: "Always ON", - FALSE: "Always OFF", - DECOMPOSE: "Splits a value of several bits, from the highest digit down", - AGGREGATE: "Joins values into one, the upper pins as the higher digits", + AND: "ON only when both inputs are ON.", + OR: "ON when at least one input is ON.", + NOT: "Turns ON into OFF, and OFF into ON.", + XOR: "ON when exactly one input is ON.", + TRUE: "Always ON.", + FALSE: "Always OFF.", + DECOMPOSE: + "Splits a value of several bits, the higher digits to the upper pins.", + AGGREGATE: "Joins values into one, the upper pins as the higher digits.", FLIPFLOP: - "Outputs what it received at the time step before (0 at the first time step)", - CONST: "Always outputs the value written in it", - BROADCAST: "Repeats a one-bit value over several bits", - }, + "Outputs what it received at the time step before (0 at the first time step).", + CONST: "Always outputs the value written in it.", + BROADCAST: "Repeats a one-bit value over several bits.", + ANDN: "ON only when every bit of In is 1.", + ORN: "ON when any bit of In is 1.", + SEVEN_SEGMENT: + "Turns the 4-bit value of In into the shape of a hexadecimal character, 0 to F. Connect Out to a Display of resolution 4x7, and give both the same pixel order with their gear buttons.", + DISPLAY: + "While playing, shows the value of Pixels as a picture, one bit per pixel (1 is black, 0 is white). From the highest digit, the pixels go from the top left row by row in row-major order, or column by column in column-major order. The gear button sets the resolution and the pixel order.", + INPUT: + "Adds an input to the component it is placed in. Where that component is placed as a part, the input is a pin on its left. While playing, click it to change its value.", + OUTPUT: + "Adds an output to the component it is placed in. Where that component is placed as a part, the output is a pin on its right. While playing, it shows the value it receives.", + } satisfies Record, + pinBitWidth: (pinName: string, canAddPins: boolean) => + `The number in the ${pinName} pin is its number of bits. Click the pin to change it.${canAddPins ? ` "Add" adds another ${pinName} pin.` : ""}`, about: (name: string) => `About ${name}`, ofStage: "Available parts", }, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 64fb89e..fcf8ddd 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -15,18 +15,30 @@ export const ja: Messages = { }, parts: { summaries: { - AND: "両方が ON のときだけ ON", - OR: "少なくとも一方が ON なら ON", - NOT: "ON と OFF を逆にする", - XOR: "片方だけが ON のとき ON", - TRUE: "いつも ON", - FALSE: "いつも OFF", - DECOMPOSE: "何ビットもある値を、上の桁から順に分ける", - AGGREGATE: "上のピンを上の桁として、値を1つにまとめる", - FLIPFLOP: "1つ前のステップで受け取った値を出す(最初のステップでは 0)", - CONST: "中に書いた値をいつも出す", - BROADCAST: "1ビットの値を、同じ値が並んだ何ビットもの値に広げる", + AND: "両方が ON のときだけ ON。", + OR: "少なくとも一方が ON なら ON。", + NOT: "ON と OFF を逆にする。", + XOR: "片方だけが ON のとき ON。", + TRUE: "いつも ON。", + FALSE: "いつも OFF。", + DECOMPOSE: "何ビットもある値を、上の桁を上のピンとして分ける。", + AGGREGATE: "上のピンを上の桁として、値を1つにまとめる。", + FLIPFLOP: "1つ前のステップで受け取った値を出す(最初のステップでは 0)。", + CONST: "中に書いた値をいつも出す。", + BROADCAST: "1ビットの値を、同じ値が並んだ何ビットもの値に広げる。", + ANDN: "In のビットがすべて 1 のときだけ ON。", + ORN: "In のどれかのビットが 1 なら ON。", + SEVEN_SEGMENT: + "In の4ビットの値を、16進数の1文字(0〜F)の形にする。Out は解像度 4x7 の Display につなぎ、それぞれの歯車のボタンで、ピクセルの並び順をそろえる。", + DISPLAY: + "再生中、Pixels の値を、1ビットを1ピクセルとして絵にする(1 は黒、0 は白)。上の桁から順に、行優先なら左上から横に1行ずつ、列優先なら縦に1列ずつ並ぶ。解像度とピクセルの並び順は、歯車のボタンで変えられる。", + INPUT: + "置いたコンポーネントに、入力を1つ足す。そのコンポーネントを部品として置くと、左側のピンになる。再生中は、クリックして値を変えられる。", + OUTPUT: + "置いたコンポーネントに、出力を1つ足す。そのコンポーネントを部品として置くと、右側のピンになる。再生中は、受け取った値を見せる。", }, + pinBitWidth: (pinName, canAddPins) => + `${pinName} のピンの中の数字は、そのピンのビット数。ピンをクリックすると変えられる。${canAddPins ? `「追加」で ${pinName} のピンを増やせる。` : ""}`, about: (name) => `${name} について`, ofStage: "使える部品", }, From 70381a976e7db939c8166885c5c9596f1abf4d61 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Fri, 20 Nov 2026 21:46:23 +0900 Subject: [PATCH 2/4] docs(parts): say that pins are set while editing and added with Apply "Add" only adds a field, and the pin comes with "Apply", which the note left out; pins can be clicked only while editing. Input's value is not always changed by a click on it, as a wide value has an edit button. The Japanese Input and Output texts no longer read as the part the player placed, and Decompose's reads more naturally. Co-Authored-By: Claude Opus 5.5 --- src/components/PartDescription.test.ts | 6 +++--- src/i18n/en.ts | 4 ++-- src/i18n/ja.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/PartDescription.test.ts b/src/components/PartDescription.test.ts index f1dd0eb..9243bac 100644 --- a/src/components/PartDescription.test.ts +++ b/src/components/PartDescription.test.ts @@ -14,16 +14,16 @@ const { en, ja } = messagesByLanguage; describe("pinNotesOf", () => { it("tells how to set a pin whose bit width the player chooses", () => { expect(pinNotesOf(en, broadcast)).toEqual([ - "The number in the Out pin is its number of bits. Click the pin to change it.", + 'The number in the Out pin is its number of bits. To change it, click the pin while editing, change the field and press "Apply".', ]); }); it("tells how to add pins where a pin can be split", () => { expect(pinNotesOf(en, and_n)).toEqual([ - 'The number in the In pin is its number of bits. Click the pin to change it. "Add" adds another In pin.', + 'The number in the In pin is its number of bits. To change it, click the pin while editing, change the field and press "Apply". Each field added with "Add" becomes another In pin.', ]); expect(pinNotesOf(ja, decompose)).toEqual([ - "Out のピンの中の数字は、そのピンのビット数。ピンをクリックすると変えられる。「追加」で Out のピンを増やせる。", + "Out のピンの中の数字は、そのピンのビット数。編集中にピンをクリックし、出てきた欄で変えて「適用」を押す。「追加」で欄を増やすと、Out のピンも増える。", ]); }); diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 64d941b..efd5ebf 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -119,12 +119,12 @@ export const en = { DISPLAY: "While playing, shows the value of Pixels as a picture, one bit per pixel (1 is black, 0 is white). From the highest digit, the pixels go from the top left row by row in row-major order, or column by column in column-major order. The gear button sets the resolution and the pixel order.", INPUT: - "Adds an input to the component it is placed in. Where that component is placed as a part, the input is a pin on its left. While playing, click it to change its value.", + "Adds an input to the component it is placed in. Where that component is placed as a part, the input is a pin on its left. While playing, its value can be changed here.", OUTPUT: "Adds an output to the component it is placed in. Where that component is placed as a part, the output is a pin on its right. While playing, it shows the value it receives.", } satisfies Record, pinBitWidth: (pinName: string, canAddPins: boolean) => - `The number in the ${pinName} pin is its number of bits. Click the pin to change it.${canAddPins ? ` "Add" adds another ${pinName} pin.` : ""}`, + `The number in the ${pinName} pin is its number of bits. To change it, click the pin while editing, change the field and press "Apply".${canAddPins ? ` Each field added with "Add" becomes another ${pinName} pin.` : ""}`, about: (name: string) => `About ${name}`, ofStage: "Available parts", }, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index fcf8ddd..38001b7 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -21,7 +21,7 @@ export const ja: Messages = { XOR: "片方だけが ON のとき ON。", TRUE: "いつも ON。", FALSE: "いつも OFF。", - DECOMPOSE: "何ビットもある値を、上の桁を上のピンとして分ける。", + DECOMPOSE: "何ビットもある値を、上の桁から順に、上のピンへ分ける。", AGGREGATE: "上のピンを上の桁として、値を1つにまとめる。", FLIPFLOP: "1つ前のステップで受け取った値を出す(最初のステップでは 0)。", CONST: "中に書いた値をいつも出す。", @@ -33,12 +33,12 @@ export const ja: Messages = { DISPLAY: "再生中、Pixels の値を、1ビットを1ピクセルとして絵にする(1 は黒、0 は白)。上の桁から順に、行優先なら左上から横に1行ずつ、列優先なら縦に1列ずつ並ぶ。解像度とピクセルの並び順は、歯車のボタンで変えられる。", INPUT: - "置いたコンポーネントに、入力を1つ足す。そのコンポーネントを部品として置くと、左側のピンになる。再生中は、クリックして値を変えられる。", + "置いた先のコンポーネントに、入力を1つ足す。そのコンポーネントを部品として置くと、左側のピンになる。再生中は、ここで値を変えられる。", OUTPUT: - "置いたコンポーネントに、出力を1つ足す。そのコンポーネントを部品として置くと、右側のピンになる。再生中は、受け取った値を見せる。", + "置いた先のコンポーネントに、出力を1つ足す。そのコンポーネントを部品として置くと、右側のピンになる。再生中は、受け取った値を見せる。", }, pinBitWidth: (pinName, canAddPins) => - `${pinName} のピンの中の数字は、そのピンのビット数。ピンをクリックすると変えられる。${canAddPins ? `「追加」で ${pinName} のピンを増やせる。` : ""}`, + `${pinName} のピンの中の数字は、そのピンのビット数。編集中にピンをクリックし、出てきた欄で変えて「適用」を押す。${canAddPins ? `「追加」で欄を増やすと、${pinName} のピンも増える。` : ""}`, about: (name) => `${name} について`, ofStage: "使える部品", }, From b217545a242c445389644b909c21f0d19488df00 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Fri, 20 Nov 2026 21:56:07 +0900 Subject: [PATCH 3/4] docs(parts): say what 7seg's Out is instead of where to connect it Out can also be joined with others by an Aggregate before a Display, as the stopwatch stage does. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 2 +- src/i18n/ja.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index efd5ebf..4cdbb36 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -115,7 +115,7 @@ export const en = { ANDN: "ON only when every bit of In is 1.", ORN: "ON when any bit of In is 1.", SEVEN_SEGMENT: - "Turns the 4-bit value of In into the shape of a hexadecimal character, 0 to F. Connect Out to a Display of resolution 4x7, and give both the same pixel order with their gear buttons.", + "Turns the 4-bit value of In into the shape of a hexadecimal character, 0 to F. Out is a 28-bit value of a picture 4 pixels wide and 7 high, with 1 for the character. The gear button sets its pixel order.", DISPLAY: "While playing, shows the value of Pixels as a picture, one bit per pixel (1 is black, 0 is white). From the highest digit, the pixels go from the top left row by row in row-major order, or column by column in column-major order. The gear button sets the resolution and the pixel order.", INPUT: diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 38001b7..eef452a 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -29,7 +29,7 @@ export const ja: Messages = { ANDN: "In のビットがすべて 1 のときだけ ON。", ORN: "In のどれかのビットが 1 なら ON。", SEVEN_SEGMENT: - "In の4ビットの値を、16進数の1文字(0〜F)の形にする。Out は解像度 4x7 の Display につなぎ、それぞれの歯車のボタンで、ピクセルの並び順をそろえる。", + "In の4ビットの値を、16進数の1文字(0〜F)の形にする。Out は、横4・縦7ピクセルの絵を表す 28 ビットの値で、文字の部分が 1。ピクセルの並び順は、歯車のボタンで変えられる。", DISPLAY: "再生中、Pixels の値を、1ビットを1ピクセルとして絵にする(1 は黒、0 は白)。上の桁から順に、行優先なら左上から横に1行ずつ、列優先なら縦に1列ずつ並ぶ。解像度とピクセルの並び順は、歯車のボタンで変えられる。", INPUT: From df3f4091d379f1ecba26151e74d8825d658007bd Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Fri, 20 Nov 2026 21:58:44 +0900 Subject: [PATCH 4/4] docs(parts): name where Input's value is changed, and that gears show while editing Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 6 +++--- src/i18n/ja.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 4cdbb36..19bf8b4 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -115,11 +115,11 @@ export const en = { ANDN: "ON only when every bit of In is 1.", ORN: "ON when any bit of In is 1.", SEVEN_SEGMENT: - "Turns the 4-bit value of In into the shape of a hexadecimal character, 0 to F. Out is a 28-bit value of a picture 4 pixels wide and 7 high, with 1 for the character. The gear button sets its pixel order.", + "Turns the 4-bit value of In into the shape of a hexadecimal character, 0 to F. Out is a 28-bit value of a picture 4 pixels wide and 7 high, with 1 for the character. While editing, the gear button sets its pixel order.", DISPLAY: - "While playing, shows the value of Pixels as a picture, one bit per pixel (1 is black, 0 is white). From the highest digit, the pixels go from the top left row by row in row-major order, or column by column in column-major order. The gear button sets the resolution and the pixel order.", + "While playing, shows the value of Pixels as a picture, one bit per pixel (1 is black, 0 is white). From the highest digit, the pixels go from the top left row by row in row-major order, or column by column in column-major order. While editing, the gear button sets the resolution and the pixel order.", INPUT: - "Adds an input to the component it is placed in. Where that component is placed as a part, the input is a pin on its left. While playing, its value can be changed here.", + "Adds an input to the component it is placed in. Where that component is placed as a part, the input is a pin on its left. While playing, its value can be changed on the placed Input.", OUTPUT: "Adds an output to the component it is placed in. Where that component is placed as a part, the output is a pin on its right. While playing, it shows the value it receives.", } satisfies Record, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index eef452a..0e21983 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -29,11 +29,11 @@ export const ja: Messages = { ANDN: "In のビットがすべて 1 のときだけ ON。", ORN: "In のどれかのビットが 1 なら ON。", SEVEN_SEGMENT: - "In の4ビットの値を、16進数の1文字(0〜F)の形にする。Out は、横4・縦7ピクセルの絵を表す 28 ビットの値で、文字の部分が 1。ピクセルの並び順は、歯車のボタンで変えられる。", + "In の4ビットの値を、16進数の1文字(0〜F)の形にする。Out は、横4・縦7ピクセルの絵を表す28ビットの値で、文字の部分が 1。ピクセルの並び順は、編集中に歯車のボタンで変えられる。", DISPLAY: - "再生中、Pixels の値を、1ビットを1ピクセルとして絵にする(1 は黒、0 は白)。上の桁から順に、行優先なら左上から横に1行ずつ、列優先なら縦に1列ずつ並ぶ。解像度とピクセルの並び順は、歯車のボタンで変えられる。", + "再生中、Pixels の値を、1ビットを1ピクセルとして絵にする(1 は黒、0 は白)。上の桁から順に、行優先なら左上から横に1行ずつ、列優先なら縦に1列ずつ並ぶ。解像度とピクセルの並び順は、編集中に歯車のボタンで変えられる。", INPUT: - "置いた先のコンポーネントに、入力を1つ足す。そのコンポーネントを部品として置くと、左側のピンになる。再生中は、ここで値を変えられる。", + "置いた先のコンポーネントに、入力を1つ足す。そのコンポーネントを部品として置くと、左側のピンになる。再生中は、置いた Input の上で値を変えられる。", OUTPUT: "置いた先のコンポーネントに、出力を1つ足す。そのコンポーネントを部品として置くと、右側のピンになる。再生中は、受け取った値を見せる。", },