Skip to content

Slct Listpatch#1251

Closed
Zurphing wants to merge 5 commits intoOpenKH:masterfrom
Zurphing:slct_listpatch
Closed

Slct Listpatch#1251
Zurphing wants to merge 5 commits intoOpenKH:masterfrom
Zurphing:slct_listpatch

Conversation

@Zurphing
Copy link
Contributor

@Zurphing Zurphing commented Feb 22, 2026

Adds Slct Listpatching for the file 14mission.bar, documentation, & tests.

Summary by CodeRabbit

  • New Features

    • Added serialization support for Kingdom Hearts II select menu entries, enabling read/write of menu definitions.
    • Added mod patching capability to merge and apply select menu configurations.
  • Documentation

    • Added guide and YAML examples for creating and modifying select menu assets.
  • Tests

    • Added tests covering select menu list patching workflows and validation.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

Adds KH2 "slct" (select-menu) support: new Slct and ChoiceEntry types with binary serialization, patcher handling to merge slct listpatches, unit tests for listpatch behavior, and documentation updates including a slct source example.

Changes

Cohort / File(s) Summary
Data Structures
OpenKh.Kh2/Slct.cs
New ChoiceEntry and Slct classes with Data attributes, fixed-size arrays, and static Read(Stream) / Write(Stream, IEnumerable<Slct>) helpers (version=2).
Patcher
OpenKh.Patcher/PatcherProcessor.cs
Added handling for "slct" listpatch: reads existing Slct list, deserializes YAML mod entries to Kh2.Slct, merges by Id (update or append), and writes merged list back to stream.
Tests
OpenKh.Tests/Patcher/PatcherTests.cs
Added ListPatchSlctTest to validate slct listpatching: embeds slct patch in a bar, runs patcher, and asserts resulting Slct entries (Id, ChoiceNum, ChoiceDefault).
Docs
docs/tool/GUI.ModsManager/creatingMods.md
Added slct asset type to listpatch docs, TOC entry, and a YAML example showing all Slct fields (choices, sequences, flags, padding).

Sequence Diagram(s)

sequenceDiagram
    participant ModFile as Mod YAML (slct)
    participant Patcher as PatcherProcessor
    participant BarStream as Game Bar Stream
    participant Serializer as Kh2.Slct (BaseTable)

    ModFile->>Patcher: provide slct entries
    BarStream->>Patcher: open existing slct data
    Patcher->>Serializer: Read existing list from stream
    Serializer-->>Patcher: existing List<Slct>
    Patcher->>Serializer: Deserialize mod YAML -> List<Slct>
    Patcher->>Patcher: Merge by Id (update or append)
    Patcher->>Serializer: Write merged List<Slct> to stream (version=2)
    Serializer-->>BarStream: write bytes
    Patcher-->>ModFile: patch complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • kenjiuno

Poem

Hop-hop, I nibble bytes with glee, 🐰
Choices lined up, four by four, you see,
Ids and messages snug in rows,
Patcher hops, the new list grows,
Menu blossoms — modder's tea! 🍵

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Slct Listpatch' directly and clearly summarizes the main change: introducing listpatching support for the Slct file type, which is the primary objective across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
OpenKh.Tests/Patcher/PatcherTests.cs (1)

3190-3274: Consider asserting Choice and Padding contents as well.
Right now the test only checks Id/ChoiceNum/ChoiceDefault; validating choice entries and padding would better guard against serialization regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@OpenKh.Tests/Patcher/PatcherTests.cs` around lines 3190 - 3274, In
ListPatchSlctTest, extend the assertions after reading slctStream to validate
the Choice and Padding arrays: verify slctStream[0].Choice has length 4 and each
element is a Kh2.ChoiceEntry with Id == 0 and MessageId == 0, and verify
slctStream[0].Padding has length 25 and contains the expected zero bytes (or the
exact values written); update the test (in the ListPatchSlctTest method,
referencing slctStream, Choice and Padding) to include these checks to catch
serialization regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/tool/GUI.ModsManager/creatingMods.md`:
- Around line 868-892: The fenced code block under the "slct Source Example"
should declare the language to satisfy markdownlint MD040; update the
triple-backtick fence that currently contains the `slct` YAML example to use a
language identifier (e.g., ```yaml) so the block is highlighted and linted
correctly, leaving the inner content (fields like Id, ChoiceNum, ChoiceDefault,
BaseSequence, TitleSequence, Padding, etc.) unchanged.

---

Nitpick comments:
In `@OpenKh.Tests/Patcher/PatcherTests.cs`:
- Around line 3190-3274: In ListPatchSlctTest, extend the assertions after
reading slctStream to validate the Choice and Padding arrays: verify
slctStream[0].Choice has length 4 and each element is a Kh2.ChoiceEntry with Id
== 0 and MessageId == 0, and verify slctStream[0].Padding has length 25 and
contains the expected zero bytes (or the exact values written); update the test
(in the ListPatchSlctTest method, referencing slctStream, Choice and Padding) to
include these checks to catch serialization regressions.

Comment on lines 868 to 892
### `slct` Source Example
```
- Id: 1
ChoiceNum: 4 #Amount of options
ChoiceDefault: 3 #Option to default to
Choice:
- Id: 0 #Choice "Function"
MessageId: 0 #MessageID to assign to the Choice
- Id: 1
MessageId: 1
- Id: 2
MessageId: 2
- Id: 3
MessageId: 3
BaseSequence: 12 #Signed short, can be negative
TitleSequence: 13 #Signed short, can be negative
Information: 14
EntryId: 15
Task: 16
PauseMode: 17
Flag: 18
SoundPause: 19
Padding: #There are 25 padding bytes in total
- 0
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language identifier to the slct YAML fence.
markdownlint MD040 flags the fenced block without a language.

💡 Suggested fix
-```
+```yaml
 - Id: 1
   ChoiceNum: 4 `#Amount` of options
   ChoiceDefault: 3 `#Option` to default to
   Choice:
   - Id: 0 `#Choice` "Function"
     MessageId: 0 `#MessageID` to assign to the Choice
   - Id: 1
     MessageId: 1
   - Id: 2
     MessageId: 2
   - Id: 3
     MessageId: 3
   BaseSequence: 12 `#Signed` short, can be negative
   TitleSequence: 13 `#Signed` short, can be negative
   Information: 14
   EntryId: 15
   Task: 16
   PauseMode: 17
   Flag: 18
   SoundPause: 19
   Padding: `#There` are 25 padding bytes in total
   - 0
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 869-869: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/tool/GUI.ModsManager/creatingMods.md` around lines 868 - 892, The fenced
code block under the "slct Source Example" should declare the language to
satisfy markdownlint MD040; update the triple-backtick fence that currently
contains the `slct` YAML example to use a language identifier (e.g., ```yaml) so
the block is highlighted and linted correctly, leaving the inner content (fields
like Id, ChoiceNum, ChoiceDefault, BaseSequence, TitleSequence, Padding, etc.)
unchanged.

Clarified comments for PauseMode and Flag fields.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/tool/GUI.ModsManager/creatingMods.md`:
- Around line 890-892: Clarify the semantics of the "Padding" entry: update the
documentation around the "Padding" example (the line showing "- 0") to state
explicitly whether partial specification is allowed and how it's handled — if
partial lists are accepted, say "you may provide N bytes and the remaining bytes
will be zero-padded to a total of 25"; otherwise require authors to list all 25
bytes and replace the truncated example with a complete 25-byte list. Ensure the
text references the "Padding" field and the sample "- 0" so readers know which
behavior applies.
- Around line 884-885: The inline comments for the fields Information and
EntryId are inconsistent/unfinished; update the examples so they match their
comments: either change Information's example value from 14 to 0 if the note
“Value tends to always be 0” is correct, or update the comment to explain why 14
is shown (e.g., what 14 represents) so the example and note agree; also remove
the stray trailing “#” after EntryId or replace it with a concise comment
explaining EntryId (e.g., “# unique entry identifier”) so the annotation is not
left empty—edit the lines containing the Information and EntryId fields in the
docs to implement these changes.

---

Duplicate comments:
In `@docs/tool/GUI.ModsManager/creatingMods.md`:
- Line 869: The fenced code block starting at the noted location lacks a
language identifier (causing markdownlint MD040); update the opening fence from
``` to ```yaml so the block is syntax-highlighted and linted correctly (e.g.,
change the block that contains the snippet with "Id: 1" and "ChoiceNum: 4" to
start with ```yaml).

Comment on lines +884 to +885
Information: 14 #Value tends to always be 0?
EntryId: 15 #
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Resolve contradictory/incomplete inline comments on Information and EntryId.

  • Line 884: The example value is 14, but the comment reads #Value tends to always be 0?. This directly contradicts the example and will confuse mod authors. Either use 0 as the example value (matching the stated expectation) or update the comment to reflect why 14 is shown.
  • Line 885: EntryId: 15 # has a trailing # with no comment body — the annotation was started but never completed.
📝 Proposed fix
-  Information: 14 `#Value` tends to always be 0?
-  EntryId: 15 #
+  Information: 0 `#Value` tends to always be 0
+  EntryId: 15 #<describe what EntryId controls>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Information: 14 #Value tends to always be 0?
EntryId: 15 #
Information: 0 `#Value` tends to always be 0
EntryId: 15 #<describe what EntryId controls>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/tool/GUI.ModsManager/creatingMods.md` around lines 884 - 885, The inline
comments for the fields Information and EntryId are inconsistent/unfinished;
update the examples so they match their comments: either change Information's
example value from 14 to 0 if the note “Value tends to always be 0” is correct,
or update the comment to explain why 14 is shown (e.g., what 14 represents) so
the example and note agree; also remove the stray trailing “#” after EntryId or
replace it with a concise comment explaining EntryId (e.g., “# unique entry
identifier”) so the annotation is not left empty—edit the lines containing the
Information and EntryId fields in the docs to implement these changes.

Comment on lines +890 to +892
Padding: #There are 25 padding bytes in total
- 0
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify whether partial Padding is supported or if the example is intentionally truncated.

The comment states "There are 25 padding bytes in total" but the example supplies only one (- 0). It's unclear whether:

  • the reader/patcher accepts a partial list (padding the rest to zero automatically), or
  • the example is simply incomplete and mod authors must specify all 25 bytes.

If partial specification is valid, a brief note to that effect would prevent authors from accidentally writing malformed entries.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/tool/GUI.ModsManager/creatingMods.md` around lines 890 - 892, Clarify
the semantics of the "Padding" entry: update the documentation around the
"Padding" example (the line showing "- 0") to state explicitly whether partial
specification is allowed and how it's handled — if partial lists are accepted,
say "you may provide N bytes and the remaining bytes will be zero-padded to a
total of 25"; otherwise require authors to list all 25 bytes and replace the
truncated example with a complete 25-byte list. Ensure the text references the
"Padding" field and the sample "- 0" so readers know which behavior applies.

@Zurphing
Copy link
Contributor Author

Closing, will be superseded by a PR that includes this among some other ones.

@Zurphing Zurphing closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant