使用方法
/add-tutorial <gif-filename> <title-ja> <title-en>
パラメータ
gif-filename: GIFファイル名(例:how_to_draw_text.gif)title-ja: 日本語タイトル(例: "テキストをマップ上に表示する方法")title-en: 英語タイトル(例: "How to Display Text on Map")
ステップの追加
コマンド実行後、対話形式でステップを追加します:
- ステップ数を入力(2-5推奨)
- 各ステップの日本語と英語のテキストを入力
実装手順
1. Manifestファイルへの追加
manifest.json と manifest.template.json の web_accessible_resources に GIF ファイルを追加:
json1{ 2 "web_accessible_resources": [ 3 { 4 "resources": [ 5 "assets/images/tutorial/how_to_draw.gif", 6 "assets/images/tutorial/<new-gif-filename>" // 追加 7 ] 8 } 9 ] 10}
2. Tutorial クラスへの項目追加
src/features/tutorial/index.ts の tutorials 配列に新しい項目を追加:
typescript1{ 2 id: "tutorial_id", 3 titleKey: "tutorial_<id>_title", 4 gifUrl: runtime.getURL("assets/images/tutorial/<gif-filename>"), 5 steps: [ 6 "tutorial_<id>_step1", 7 "tutorial_<id>_step2", 8 "tutorial_<id>_step3", 9 ], 10}
3. 国際化キーの追加
英語 (src/i18n/locales/en.ts)
typescript1tutorial_<id>_title: "English Title", 2tutorial_<id>_step1: "Step 1 description", 3tutorial_<id>_step2: "Step 2 description", 4tutorial_<id>_step3: "Step 3 description",
日本語 (src/i18n/locales/ja.ts)
typescript1tutorial_<id>_title: "日本語タイトル", 2tutorial_<id>_step1: "ステップ1の説明", 3tutorial_<id>_step2: "ステップ2の説明", 4tutorial_<id>_step3: "ステップ3の説明",
命名規則
Tutorial ID
- フォーマット:
how_to_<action>またはhow_to_<action>_<target> - 例:
how_to_draw- 画像描画how_to_archive- アーカイブ保存how_to_draw_archive- アーカイブ描画how_to_draw_text- テキスト描画
i18n キー
- タイトル:
tutorial_<id>_title - ステップ:
tutorial_<id>_step1,tutorial_<id>_step2, ...
既存のチュートリアル例
1. 画像描画 (how_to_draw)
typescript1{ 2 id: "how_to_draw", 3 titleKey: "tutorial_how_to_draw_title", 4 gifUrl: runtime.getURL("assets/images/tutorial/how_to_draw.gif"), 5 steps: [ 6 "tutorial_how_to_draw_step1", // ギャラリーに画像を保存する 7 "tutorial_how_to_draw_step2", // マップをクリックして、「画像」ボタンを選択 8 "tutorial_how_to_draw_step3", // 配置したい画像をクリック 9 ], 10}
2. アーカイブ保存 (how_to_archive)
typescript1{ 2 id: "how_to_archive", 3 titleKey: "tutorial_how_to_archive_title", 4 gifUrl: runtime.getURL("assets/images/tutorial/how_to_archive.gif"), 5 steps: [ 6 "tutorial_how_to_archive_step1", // マップをクリックして「アーカイブ」を選択 7 "tutorial_how_to_archive_step2", // 「Save Current Tile」ボタンをクリック 8 ], 9}
3. テキスト描画 (how_to_draw_text)
typescript1{ 2 id: "how_to_draw_text", 3 titleKey: "tutorial_how_to_draw_text_title", 4 gifUrl: runtime.getURL("assets/images/tutorial/how_to_draw_text.gif"), 5 steps: [ 6 "tutorial_how_to_draw_text_step1", // マップをクリックして「テキスト」を選択 7 "tutorial_how_to_draw_text_step2", // テキストを入力し、フォントを選んで「Draw」ボタンをクリック 8 "tutorial_how_to_draw_text_step3", // オプション:矢印ボタンで位置を調節 9 ], 10}
チェックリスト
実装時に確認すべき項目:
- GIFファイルが
public/assets/images/tutorial/に配置されている -
manifest.jsonに GIF が追加されている -
manifest.template.jsonに GIF が追加されている -
src/features/tutorial/index.tsに項目が追加されている -
src/i18n/locales/en.tsに英語キーが追加されている -
src/i18n/locales/ja.tsに日本語キーが追加されている - ステップ数が2-5個の範囲である
- ID が他のチュートリアルと重複していない
ファイル構造
wplace-studio/
├── public/
│ └── assets/
│ └── images/
│ └── tutorial/
│ ├── how_to_draw.gif
│ ├── how_to_archive.gif
│ ├── how_to_draw_archive.gif
│ ├── how_to_draw_text.gif
│ └── <new-tutorial>.gif
├── manifest.json
├── manifest.template.json
└── src/
├── features/
│ └── tutorial/
│ └── index.ts
└── i18n/
└── locales/
├── en.ts
└── ja.ts
注意事項
- GIFファイルのサイズ: できるだけ軽量に(推奨: 1MB以下)
- ステップ数: 多すぎると読みにくいため、2-5個を推奨
- 命名規則: 一貫性のため
how_to_*パターンを使用 - i18nキーの順序: 既存のチュートリアルキーの後に追加
- 空状態メッセージ: 必要に応じて
empty_*_messageキーも追加
コミットメッセージ例
feat(tutorial): add <action> tutorial
- Add <gif-filename> to web accessible resources
- Add <action> tutorial to Tutorial class
- Add i18n keys for <action> tutorial (en/ja)
トラブルシューティング
GIFが表示されない
- ブラウザの開発者ツールでネットワークタブを確認
- GIF ファイルが正しいパスに配置されているか確認
- manifest.json を更新後、拡張機能を再読み込み
チュートリアルが一覧に表示されない
src/features/tutorial/index.tsの構文エラーを確認- i18n キーが正しく登録されているか確認
- ブラウザコンソールでエラーがないか確認