Move default_index to DeckBuilder#3126
Conversation
mercury233
left a comment
There was a problem hiding this comment.
don't think it is a good idea to add coupling
談耦合之前還是應該先談正確性 ygopro應該要保存驗證後的default_lflist_index |
There was a problem hiding this comment.
Pull request overview
This PR moves the “default LFList index” (from system.conf’s default_lflist) into DeckBuilder, ensuring the value used to select the LFList combobox is validated before being applied.
Changes:
- Validate
gameConf.default_lflistagainstdeckManager._lfListand store the validated value indeckBuilder.default_lflist_index. - Switch LFList combobox selection (system/settings + host dialog) to use
deckBuilder.default_lflist_index. - Persist the selected LFList index via
DeckBuilderand use it to initializeDeckBuilder::filterList.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| gframe/game.cpp | Validates config LFList index, uses DeckBuilder-managed index for UI selection, and saves it back to config. |
| gframe/event_handler.cpp | Updates LFList toggle/selection logic to read/write DeckBuilder-managed LFList index. |
| gframe/deck_con.h | Adds default_lflist_index state to DeckBuilder. |
| gframe/deck_con.cpp | Initializes filterList from the DeckBuilder-managed LFList index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mainGame->cbHostLFlist->setSelected(mainGame->gameConf.default_lflist); | ||
| mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->gameConf.default_lflist]; | ||
| int sel = mainGame->cbLFlist->getSelected(); | ||
| if (sel != -1) { |
There was a problem hiding this comment.
Currently not necessary. One empty lflist is always be pushed to deckManager._lfList, also we never clear cbLFlist, nor setSelected to -1.
There was a problem hiding this comment.
Writing -1 to index is not acceptable.
I don't think ygopro should fight against every combobox like:
Does this combobox return -1?
Surely not.
Oh wait...
I suppose that checking selected value of any combobox is a good practice.
There was a problem hiding this comment.
In practice, only the deck list combo box can be empty. The other combo boxes should never be empty in theory, so it's fine to use them directly.
default_lflist in system.conf
It is the index of _lfList and lflist combobox, and it should be validated before passing to combobox.
default_index
The validated value.
Now it is managed by DeckBuilder.