mirror of
https://github.com/sebastiandine/Card-Collection-Manager-3.git
synced 2026-09-04 09:13:27 +00:00
convenience features (#21)
This commit is contained in:
@@ -128,6 +128,14 @@ void DigiBattle99GameView::buildSingleCardsToolbar(wxWindow* parent, wxBoxSizer*
|
||||
if (filterInput_ == nullptr) return;
|
||||
setFilter(filterInput_->GetValue().ToStdString(wxConvUTF8));
|
||||
});
|
||||
filterInput_->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& ev) {
|
||||
const int code = ev.GetKeyCode();
|
||||
if (code == WXK_UP || code == WXK_DOWN) {
|
||||
nudgeSelection(code == WXK_UP ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
ev.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
void DigiBattle99GameView::refreshToolbarIcons(const ThemePalette& palette) {
|
||||
@@ -308,7 +316,7 @@ wxPanel* DigiBattle99GameView::selectedPanel(wxWindow* parent) {
|
||||
return selectedPanel_;
|
||||
}
|
||||
|
||||
void DigiBattle99GameView::refreshCollection() {
|
||||
void DigiBattle99GameView::refreshCollection(std::optional<std::uint32_t> selectId) {
|
||||
// Ensure the Digimon host (and list panel) exist even when MainFrame mounts
|
||||
// via contentPanel before an explicit listPanel call.
|
||||
if (contentPanel_ == nullptr && listPanel_ == nullptr) return;
|
||||
@@ -323,7 +331,7 @@ void DigiBattle99GameView::refreshCollection() {
|
||||
}
|
||||
auto cards = std::move(loaded).value();
|
||||
if (listPanel_ != nullptr) {
|
||||
listPanel_->setCards(cards);
|
||||
listPanel_->setCards(cards, selectId);
|
||||
listPanel_->activateSelection();
|
||||
if (selectedPanel_) selectedPanel_->setCard(listPanel_->selected());
|
||||
}
|
||||
@@ -387,7 +395,7 @@ void DigiBattle99GameView::onAddCard(wxWindow* parentWindow) {
|
||||
"Card added, but image rename to ID-prefixed format failed: " + normalized.error(),
|
||||
"Warning", wxOK | wxICON_WARNING);
|
||||
}
|
||||
refreshCollection();
|
||||
refreshCollection(added.value());
|
||||
}
|
||||
|
||||
void DigiBattle99GameView::onEditCard(wxWindow* parentWindow) {
|
||||
@@ -499,6 +507,10 @@ void DigiBattle99GameView::setFilter(std::string_view filter) {
|
||||
if (listPanel_) listPanel_->setFilter(filter);
|
||||
}
|
||||
|
||||
void DigiBattle99GameView::nudgeSelection(int delta) {
|
||||
if (listPanel_) listPanel_->nudgeSelection(delta);
|
||||
}
|
||||
|
||||
void DigiBattle99GameView::applyTheme(const ThemePalette& palette) {
|
||||
if (contentPanel_) applyThemeToWindowTree(contentPanel_, palette, config_.current().theme);
|
||||
if (listPanel_) listPanel_->applyTheme(palette);
|
||||
|
||||
@@ -71,7 +71,7 @@ wxPanel* MagicGameView::selectedPanel(wxWindow* parent) {
|
||||
return selectedPanel_;
|
||||
}
|
||||
|
||||
void MagicGameView::refreshCollection() {
|
||||
void MagicGameView::refreshCollection(std::optional<std::uint32_t> selectId) {
|
||||
if (listPanel_ == nullptr) return;
|
||||
auto loaded = collection_.list(Game::Magic);
|
||||
if (!loaded) {
|
||||
@@ -79,7 +79,7 @@ void MagicGameView::refreshCollection() {
|
||||
"Error", wxOK | wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
listPanel_->setCards(std::move(loaded).value());
|
||||
listPanel_->setCards(std::move(loaded).value(), selectId);
|
||||
listPanel_->activateSelection();
|
||||
if (selectedPanel_) selectedPanel_->setCard(listPanel_->selected());
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void MagicGameView::onAddCard(wxWindow* parentWindow) {
|
||||
showThemedMessageDialog(parentWindow, "Card added, but image rename to ID-prefixed format failed: " + normalized.error(),
|
||||
"Warning", wxOK | wxICON_WARNING);
|
||||
}
|
||||
refreshCollection();
|
||||
refreshCollection(added.value());
|
||||
}
|
||||
|
||||
void MagicGameView::onEditCard(wxWindow* parentWindow) {
|
||||
@@ -200,6 +200,10 @@ void MagicGameView::setFilter(std::string_view filter) {
|
||||
if (listPanel_) listPanel_->setFilter(filter);
|
||||
}
|
||||
|
||||
void MagicGameView::nudgeSelection(int delta) {
|
||||
if (listPanel_) listPanel_->nudgeSelection(delta);
|
||||
}
|
||||
|
||||
void MagicGameView::applyTheme(const ThemePalette& palette) {
|
||||
if (listPanel_) listPanel_->applyTheme(palette);
|
||||
if (selectedPanel_) selectedPanel_->applyTheme(palette);
|
||||
|
||||
@@ -185,6 +185,16 @@ void MainFrame::buildLayout() {
|
||||
view->setFilter(filterInput_->GetValue().ToStdString());
|
||||
}
|
||||
});
|
||||
filterInput_->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& ev) {
|
||||
const int code = ev.GetKeyCode();
|
||||
if (code == WXK_UP || code == WXK_DOWN) {
|
||||
if (auto* view = activeView()) {
|
||||
view->nudgeSelection(code == WXK_UP ? -1 : 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ev.Skip();
|
||||
});
|
||||
|
||||
// Selection changes are handled per-view (each IGameView binds
|
||||
// EVT_CARD_SELECTED on its own typed list panel and pushes the typed
|
||||
|
||||
@@ -136,6 +136,14 @@ void PokemonGameView::buildSingleCardsToolbar(wxWindow* parent, wxBoxSizer* page
|
||||
if (filterInput_ == nullptr) return;
|
||||
setFilter(filterInput_->GetValue().ToStdString(wxConvUTF8));
|
||||
});
|
||||
filterInput_->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& ev) {
|
||||
const int code = ev.GetKeyCode();
|
||||
if (code == WXK_UP || code == WXK_DOWN) {
|
||||
nudgeSelection(code == WXK_UP ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
ev.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
void PokemonGameView::refreshToolbarIcons(const ThemePalette& palette) {
|
||||
@@ -310,7 +318,7 @@ wxPanel* PokemonGameView::selectedPanel(wxWindow* parent) {
|
||||
return selectedPanel_;
|
||||
}
|
||||
|
||||
void PokemonGameView::refreshCollection() {
|
||||
void PokemonGameView::refreshCollection(std::optional<std::uint32_t> selectId) {
|
||||
if (contentPanel_ == nullptr && listPanel_ == nullptr) return;
|
||||
|
||||
auto loaded = collection_.list(Game::Pokemon);
|
||||
@@ -321,7 +329,7 @@ void PokemonGameView::refreshCollection() {
|
||||
}
|
||||
auto cards = std::move(loaded).value();
|
||||
if (listPanel_ != nullptr) {
|
||||
listPanel_->setCards(cards);
|
||||
listPanel_->setCards(cards, selectId);
|
||||
listPanel_->activateSelection();
|
||||
if (selectedPanel_) selectedPanel_->setCard(listPanel_->selected());
|
||||
}
|
||||
@@ -389,7 +397,7 @@ void PokemonGameView::onAddCard(wxWindow* parentWindow) {
|
||||
showThemedMessageDialog(parentWindow, "Card added, but image rename to ID-prefixed format failed: " + normalized.error(),
|
||||
"Warning", wxOK | wxICON_WARNING);
|
||||
}
|
||||
refreshCollection();
|
||||
refreshCollection(added.value());
|
||||
}
|
||||
|
||||
void PokemonGameView::onEditCard(wxWindow* parentWindow) {
|
||||
@@ -582,6 +590,10 @@ void PokemonGameView::setFilter(std::string_view filter) {
|
||||
if (listPanel_) listPanel_->setFilter(filter);
|
||||
}
|
||||
|
||||
void PokemonGameView::nudgeSelection(int delta) {
|
||||
if (listPanel_) listPanel_->nudgeSelection(delta);
|
||||
}
|
||||
|
||||
void PokemonGameView::applyTheme(const ThemePalette& palette) {
|
||||
if (contentPanel_) applyThemeToWindowTree(contentPanel_, palette, config_.current().theme);
|
||||
if (listPanel_) listPanel_->applyTheme(palette);
|
||||
|
||||
@@ -134,6 +134,14 @@ void YuGiOhGameView::buildSingleCardsToolbar(wxWindow* parent, wxBoxSizer* pageS
|
||||
if (filterInput_ == nullptr) return;
|
||||
setFilter(filterInput_->GetValue().ToStdString(wxConvUTF8));
|
||||
});
|
||||
filterInput_->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& ev) {
|
||||
const int code = ev.GetKeyCode();
|
||||
if (code == WXK_UP || code == WXK_DOWN) {
|
||||
nudgeSelection(code == WXK_UP ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
ev.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
void YuGiOhGameView::refreshToolbarIcons(const ThemePalette& palette) {
|
||||
@@ -308,7 +316,7 @@ wxPanel* YuGiOhGameView::selectedPanel(wxWindow* parent) {
|
||||
return selectedPanel_;
|
||||
}
|
||||
|
||||
void YuGiOhGameView::refreshCollection() {
|
||||
void YuGiOhGameView::refreshCollection(std::optional<std::uint32_t> selectId) {
|
||||
if (contentPanel_ == nullptr && listPanel_ == nullptr) return;
|
||||
|
||||
auto loaded = collection_.list(Game::YuGiOh);
|
||||
@@ -319,7 +327,7 @@ void YuGiOhGameView::refreshCollection() {
|
||||
}
|
||||
auto cards = std::move(loaded).value();
|
||||
if (listPanel_ != nullptr) {
|
||||
listPanel_->setCards(cards);
|
||||
listPanel_->setCards(cards, selectId);
|
||||
listPanel_->activateSelection();
|
||||
if (selectedPanel_) selectedPanel_->setCard(listPanel_->selected());
|
||||
}
|
||||
@@ -391,7 +399,7 @@ void YuGiOhGameView::onAddCard(wxWindow* parentWindow) {
|
||||
"Card added, but image rename to ID-prefixed format failed: " + normalized.error(),
|
||||
"Warning", wxOK | wxICON_WARNING);
|
||||
}
|
||||
refreshCollection();
|
||||
refreshCollection(added.value());
|
||||
}
|
||||
|
||||
void YuGiOhGameView::onEditCard(wxWindow* parentWindow) {
|
||||
@@ -505,6 +513,10 @@ void YuGiOhGameView::setFilter(std::string_view filter) {
|
||||
if (listPanel_) listPanel_->setFilter(filter);
|
||||
}
|
||||
|
||||
void YuGiOhGameView::nudgeSelection(int delta) {
|
||||
if (listPanel_) listPanel_->nudgeSelection(delta);
|
||||
}
|
||||
|
||||
void YuGiOhGameView::applyTheme(const ThemePalette& palette) {
|
||||
if (contentPanel_) applyThemeToWindowTree(contentPanel_, palette, config_.current().theme);
|
||||
if (listPanel_) listPanel_->applyTheme(palette);
|
||||
|
||||
Reference in New Issue
Block a user