diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 1dad934..62463c1 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1,4 +1,5 @@ import { englishSimulationErrorTexts } from "../store/simulationErrorTexts"; +import type { TutorialStageId } from "../tutorial/stages"; const bitWidths = (widths: readonly number[]) => `${widths.join("/")} bit`; const listOf = (names: readonly string[]) => @@ -8,6 +9,32 @@ const listOf = (names: readonly string[]) => const themOf = (names: readonly string[]) => names.length === 1 ? "it" : "them"; +type StageTexts = { title: string; goal: string; steps: readonly string[] }; + +const stageTexts: Record = { + and: { + title: "Both switches", + goal: "Make the lamp Out light up only when both switches A and B are ON. The stage is cleared when the circuit works as in the table below.", + steps: [ + "Pick a part in the Parts list and drag it onto the editor on the right.", + "The small squares on the edges of a part are its pins. A pin on the left side is an input, which receives ON or OFF, and a pin on the right side is an output, which sends ON or OFF. Drag between an output pin and an input pin to connect them with a wire.", + "Once Out and every input pin of the parts you placed are connected, the play button at the bottom right can be pressed. It cannot be pressed while a part has a free input pin.", + "After pressing it, click the switches A and B to turn them ON and OFF, and watch the lamp Out. To fix the circuit, the pencil button in the same place takes you back to editing.", + "When it works as in the table, press Check.", + ], + }, + "a-only": { + title: "Only switch A", + goal: "Make the lamp Out light up only when switch A is ON and B is OFF. This time, one part alone is not enough.", + steps: [], + }, + xor: { + title: "Only one switch", + goal: 'Make the lamp Out light up when exactly one of the switches A and B is ON. It does not light up when both are ON. "Only switch A" is ready to use as a part.', + steps: [], + }, +}; + export const en = { languageName: "English", common: { @@ -107,6 +134,7 @@ export const en = { stages: "Stages", parts: "Parts", goalHeading: "Goal", + stepsHeading: "Steps", check: "Check", passed: "Cleared! The circuit works for every combination of the inputs.", next: "Next stage", @@ -129,20 +157,7 @@ export const en = { confirm: "Reset", }, resetStageFailed: "Could not reset the stage.", - stageTexts: { - and: { - title: "Both switches", - goal: "Make the lamp Out light up only when both switches A and B are ON. Drag parts from the Parts list onto the editor, and drag from pin to pin to connect them. The play button at the bottom right lets you try the switches. When it works, press Check.", - }, - "a-only": { - title: "Only switch A", - goal: "Make the lamp Out light up only when switch A is ON and B is OFF. This time, one part alone is not enough.", - }, - xor: { - title: "Only one switch", - goal: 'Make the lamp Out light up when exactly one of the switches A and B is ON. It does not light up when both are ON. "Only switch A" is ready to use as a part.', - }, - }, + stageTexts, }, componentProperties: { title: (componentName: string) => `${componentName} Properties`, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index aa26f47..1dd86fd 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -102,6 +102,7 @@ export const ja: Messages = { stages: "課題の一覧", parts: "部品", goalHeading: "目標", + stepsHeading: "手順", check: "確かめる", passed: "クリア!どの入力の組み合わせでも正しく動きます。", next: "次の課題へ", @@ -122,15 +123,24 @@ export const ja: Messages = { stageTexts: { and: { title: "両方のスイッチ", - goal: "スイッチ A と B が両方 ON のときだけ、ランプ Out がつくようにしましょう。「部品」の一覧から部品をエディタにドラッグして置き、ピンからピンへドラッグしてつなぎます。右下の再生ボタンで、スイッチを切り替えて試せます。できたら「確かめる」を押してください。", + goal: "スイッチ A と B が両方 ON のときだけ、ランプ Out がつくようにしましょう。下の表のとおりに動けばクリアです。", + steps: [ + "「部品」の一覧から部品を選び、右のエディタにドラッグして置きます。", + "部品の端にある小さな四角を「ピン」といいます。左側のピンは ON か OFF を受け取る「入力」、右側のピンは ON か OFF を送り出す「出力」です。出力のピンと入力のピンのあいだをドラッグして、線でつなぎます。", + "Out と、置いた部品の入力のピンがすべてつながると、右下の再生ボタンが押せるようになります。入力のピンが空いている部品が残っていると押せません。", + "再生ボタンを押したら、スイッチ A と B をクリックして ON と OFF を切り替え、ランプ Out を見ます。回路を直すときは、同じ場所の鉛筆のボタンで編集に戻ります。", + "表のとおりに動いたら、「確かめる」を押します。", + ], }, "a-only": { title: "A だけのスイッチ", goal: "スイッチ A が ON で、B が OFF のときだけ、ランプ Out がつくようにしましょう。今度は、部品を1つ置くだけではできません。", + steps: [], }, xor: { title: "片方だけのスイッチ", goal: "スイッチ A と B のどちらか片方だけが ON のときに、ランプ Out がつくようにしましょう。両方 ON のときはつきません。「A だけのスイッチ」を部品として使えます。", + steps: [], }, }, }, diff --git a/src/pages/tutorial/stage.tsx b/src/pages/tutorial/stage.tsx index 4909b1e..a500e9b 100644 --- a/src/pages/tutorial/stage.tsx +++ b/src/pages/tutorial/stage.tsx @@ -103,6 +103,7 @@ function StageView({ stage }: { stage: TutorialStage }) { const nextStage = tutorialStages[stageIndex + 1]; const titleOf: StageTitleOf = (id) => texts.stageTexts[id].title; const goalTable = truthTableOfCheck(stage.check); + const stageTexts = texts.stageTexts[stage.id]; const [store, setStore] = useState(() => getTutorialStageStore(stage, titleOf), @@ -160,92 +161,114 @@ function StageView({ stage }: { stage: TutorialStage }) { minHeight: 0, }} > - - - - {texts.stages} - -
- - {texts.stageNumber(stageIndex + 1)} - - - {texts.stageTexts[stage.id].title} - -
-
- {texts.goalHeading} - {texts.stageTexts[stage.id].goal} - {goalTable && ( - - - - )} -
- - {result?.type === "passed" && ( - <> - {texts.passed} - - - )} - {result && result.type !== "passed" && ( - - {describeFailure(result, store, messages)} - - )} -
- {messages.parts.ofStage} - - {stage.parts.map((partId) => ( - - ))} - {stage.givenParts.map((id) => ( - - ))} - -
- - {hasResetFailed && ( - {texts.resetStageFailed} - )} - -
+ {stageTexts.title} + + +
+ {texts.goalHeading} + {stageTexts.goal} + {goalTable && ( + + + + )} +
+ {stageTexts.steps.length > 0 && ( +
+ {texts.stepsHeading} + + {stageTexts.steps.map((step) => ( + + {step} + + ))} + +
+ )} +
+ {messages.parts.ofStage} + + {stage.parts.map((partId) => ( + + ))} + {stage.givenParts.map((id) => ( + + ))} + +
+ + {hasResetFailed && ( + {texts.resetStageFailed} + )} + + + + {/* Outside the scrolling, so that Check and its result stay in view */} + + + {result?.type === "passed" && ( + <> + {texts.passed} + + + )} + {result && result.type !== "passed" && ( + + {describeFailure(result, store, messages)} + + )} + +