From 67b7abd17dd1aa0ddcaa32af0f97a08953d9ef76 Mon Sep 17 00:00:00 2001 From: void2610 Date: Sat, 5 Sep 2026 02:53:46 +0900 Subject: [PATCH] =?UTF-8?q?refac:=20=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92=E3=82=BB?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E6=9E=A0=E3=81=A8=E8=A1=8C?= =?UTF-8?q?=E6=8F=83=E3=81=88=E3=81=A7=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Novel/CHANGELOG.md | 2 + Assets/Novel/Editor/ProjectReferenceWindow.cs | 96 +++++++++++++------ 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/Assets/Novel/CHANGELOG.md b/Assets/Novel/CHANGELOG.md index 9942914..fb2a14c 100644 --- a/Assets/Novel/CHANGELOG.md +++ b/Assets/Novel/CHANGELOG.md @@ -96,6 +96,8 @@ - `NovelDisplayText.Build` を公開。自前 View が `TextRevealEngine` の可視文字数と整合する TMP 文字列構築を再実装せずに済む。 ### Changed +- Project Reference の「コマンド」タブの表示を整理。セクションを枠で囲み、名前 + 説明を 1 行目・引数を + インデントした 2 行目に揃え、縞背景で行を区切る。C# コマンド型名の表示は削除 (名前から自明なため) - **破壊的**: `IWorldEffectSink` に `EnumerateKeys()` を追加 (default 実装なし。音キーと同じく実装忘れが沈黙の空目録に なるため明示実装を要求する。一覧を持てない実装は空を返す) - **破壊的**: `INovelCommandModule.RegisterVocabulary` の引数が `MRubyState` から `INovelVocabulary` になった。 diff --git a/Assets/Novel/Editor/ProjectReferenceWindow.cs b/Assets/Novel/Editor/ProjectReferenceWindow.cs index 86a71cb..625723f 100644 --- a/Assets/Novel/Editor/ProjectReferenceWindow.cs +++ b/Assets/Novel/Editor/ProjectReferenceWindow.cs @@ -590,8 +590,7 @@ private void DrawCommands(NovelProjectCapture.Snapshot? snapshot) return; } EditorGUILayout.LabelField( - $"{FormatTime(snapshot.CapturedAt)} の再生時に取得。コピーはそのまま書ける呼び出し形 " + - "(糖衣: 必須引数は名前・省略可は既定値 / コマンド: cmd + キーワード引数に型ごとの空値 / world_effect: キーのみ)。", + $"{FormatTime(snapshot.CapturedAt)} の再生時に取得。コピーはそのまま .rb に書ける呼び出し形。", EditorStyles.miniLabel); DrawPreambleSugars(snapshot.Preambles); @@ -611,20 +610,30 @@ private void DrawPreambleSugars(IReadOnlyList preambles) var names = preamble.MethodNames.Where(Matches).ToList(); if (names.Count == 0) continue; - if (entry != null) DrawPingableHeader($"糖衣: {entry.AssetPath} ({names.Count})", entry.AssetPath); - else EditorGUILayout.LabelField($"糖衣: {preamble.SourceType} ({names.Count}) — ソース .rb が見つからないため名前のみ", EditorStyles.miniBoldLabel); - - foreach (var name in names) + using (new EditorGUILayout.VerticalScope(SectionBox)) { - var def = defs != null && defs.TryGetValue(name, out var d) ? d : null; - using (new EditorGUILayout.HorizontalScope()) + if (entry != null) DrawPingableHeader($"糖衣 — {entry.AssetPath} ({names.Count})", entry.AssetPath); + else + { + EditorGUILayout.LabelField($"糖衣 — {preamble.SourceType} ({names.Count})", EditorStyles.boldLabel); + EditorGUILayout.LabelField("ソース .rb が見つからないため名前のみ", EditorStyles.miniLabel); + } + var row = 0; + foreach (var name in names) { - DrawKeyChip(name, def?.CallTemplate() ?? name, 160f); - EditorGUILayout.LabelField(def?.Signature() ?? "", EditorStyles.miniLabel); + var def = defs != null && defs.TryGetValue(name, out var d) ? d : null; + BeginZebraRow(row++); + using (new EditorGUILayout.HorizontalScope()) + { + DrawKeyChip(name, def?.CallTemplate() ?? name, 180f); + if (def?.Comment != null) EditorGUILayout.LabelField(def.Comment, RowLabel); + } + if (def != null && def.Params.Count > 0) + DrawDetailLine(def.Signature()); + EditorGUILayout.EndVertical(); } - if (def?.Comment != null) - EditorGUILayout.LabelField($" {def.Comment}", EditorStyles.wordWrappedMiniLabel); } + EditorGUILayout.Space(6f); } } @@ -636,20 +645,25 @@ private void DrawCommandModules(IReadOnlyList commands) { var rows = group.Where(c => Matches(c.Name) || Matches(c.CommandType)).OrderBy(c => c.Name, StringComparer.Ordinal).ToList(); if (rows.Count == 0) continue; - EditorGUILayout.LabelField($"コマンド: {group.Key} ({rows.Count})", EditorStyles.miniBoldLabel); - foreach (var command in rows) + using (new EditorGUILayout.VerticalScope(SectionBox)) { - using (new EditorGUILayout.HorizontalScope()) + EditorGUILayout.LabelField($"コマンド — {group.Key} ({rows.Count})", EditorStyles.boldLabel); + var row = 0; + foreach (var command in rows) { - DrawKeyChip(command.Name, CommandTemplate(command), 160f); - var parameters = string.Join(" ", command.Parameters.Select(p => $"{p.Name}: {p.TypeName}")); - EditorGUILayout.LabelField($"{parameters} ({command.CommandType})", EditorStyles.miniLabel); + BeginZebraRow(row++); + using (new EditorGUILayout.HorizontalScope()) + { + DrawKeyChip(command.Name, CommandTemplate(command), 180f); + if (command.Description != null) EditorGUILayout.LabelField(command.Description, RowLabel); + } + if (command.Parameters.Count > 0) + DrawDetailLine(string.Join(", ", command.Parameters.Select(p => + p.Description == null ? $"{p.Name}: {p.TypeName}" : $"{p.Name}: {p.TypeName} — {p.Description}"))); + EditorGUILayout.EndVertical(); } - if (command.Description != null) - EditorGUILayout.LabelField($" {command.Description}", EditorStyles.wordWrappedMiniLabel); - foreach (var p in command.Parameters.Where(p => p.Description != null)) - EditorGUILayout.LabelField($" {p.Name}: {p.Description}", EditorStyles.wordWrappedMiniLabel); } + EditorGUILayout.Space(6f); } } @@ -659,17 +673,45 @@ private void DrawWorldEffectKeys(NovelProjectCapture.Snapshot snapshot) { var rows = snapshot.WorldEffectKeys.Where(k => Matches(k.Key)).OrderBy(k => k.Key, StringComparer.Ordinal).ToList(); if (rows.Count == 0) return; - EditorGUILayout.LabelField($"world_effect: {snapshot.WorldEffectSinkType} ({rows.Count})", EditorStyles.miniBoldLabel); - foreach (var key in rows) + using (new EditorGUILayout.VerticalScope(SectionBox)) { - using (new EditorGUILayout.HorizontalScope()) + EditorGUILayout.LabelField($"world_effect — {snapshot.WorldEffectSinkType} ({rows.Count})", EditorStyles.boldLabel); + var row = 0; + foreach (var key in rows) { - DrawKeyChip($":{key.Key}", $"world_effect :{key.Key}", 160f); - EditorGUILayout.LabelField(key.Note ?? "", EditorStyles.miniLabel); + BeginZebraRow(row++); + using (new EditorGUILayout.HorizontalScope()) + { + DrawKeyChip($":{key.Key}", $"world_effect :{key.Key}", 180f); + if (key.Note != null) EditorGUILayout.LabelField(key.Note, RowLabel); + } + EditorGUILayout.EndVertical(); } } } + // ---- コマンドタブの共通描画 (セクション枠・縞背景・詳細行) ---- + + private static GUIStyle? _sectionBox; + private static GUIStyle SectionBox => _sectionBox ??= new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(8, 8, 6, 6) }; + + /// 縞背景つきエントリの開始。EndVertical で閉じる (Scope にしないのは背景を内容より先に描くため)。 + private static void BeginZebraRow(int index) + { + var rect = EditorGUILayout.BeginVertical(); + if (Event.current.type == EventType.Repaint && (index & 1) == 1) + EditorGUI.DrawRect(rect, new Color(0.5f, 0.5f, 0.5f, 0.08f)); + } + + /// エントリ 2 行目の補足 (引数など)。チップの文字位置に揃えてインデントする。 + private static void DrawDetailLine(string text) + { + var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); + const float indent = 4f + CopyButtonWidth + ChipGap; + EditorGUI.LabelField(new Rect(rect.x + indent, rect.y, Mathf.Max(0f, rect.width - indent), rect.height), + text, EditorStyles.miniLabel); + } + // ---- 共通描画 ---- private const float CopyButtonWidth = 22f;