mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Card list sorting is now handled per window (closes #71)
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
-- HEAD: new items added as changes are made
|
-- HEAD: new items added as changes are made
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Sorting of the card list can now be changed per window
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
* Fixed: keywords after atoms were not showing up (#67)
|
* Fixed: keywords after atoms were not showing up (#67)
|
||||||
* Fixed: multiple keywords that matched in the same place both showed reminder text. (#70)
|
* Fixed: multiple keywords that matched in the same place both showed reminder text. (#70)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <gui/control/card_list.hpp>
|
#include <gui/control/card_list.hpp>
|
||||||
#include <gui/control/card_list_column_select.hpp>
|
#include <gui/control/card_list_column_select.hpp>
|
||||||
|
#include <gui/set/window.hpp> // for sorting all cardlists in a window
|
||||||
#include <gui/util.hpp>
|
#include <gui/util.hpp>
|
||||||
#include <data/game.hpp>
|
#include <data/game.hpp>
|
||||||
#include <data/field.hpp>
|
#include <data/field.hpp>
|
||||||
@@ -44,19 +45,12 @@ CardListBase* CardSelectEvent::getTheCardList() const {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : CardListBase
|
// ----------------------------------------------------------------------------- : CardListBase
|
||||||
|
|
||||||
vector<CardListBase*> CardListBase::card_lists;
|
|
||||||
|
|
||||||
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
||||||
: ItemList(parent, id, additional_style, true)
|
: ItemList(parent, id, additional_style, true)
|
||||||
{
|
{}
|
||||||
// add to the list of card lists
|
|
||||||
card_lists.push_back(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
CardListBase::~CardListBase() {
|
CardListBase::~CardListBase() {
|
||||||
storeColumns();
|
storeColumns();
|
||||||
// remove from list of card lists
|
|
||||||
card_lists.erase(remove(card_lists.begin(), card_lists.end(), this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardListBase::onBeforeChangeSet() {
|
void CardListBase::onBeforeChangeSet() {
|
||||||
@@ -263,10 +257,15 @@ void CardListBase::rebuild() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CardListBase::sortBy(long column, bool ascending) {
|
void CardListBase::sortBy(long column, bool ascending) {
|
||||||
// sort all card lists for this game
|
ItemList::sortBy(column, ascending);
|
||||||
FOR_EACH(card_list, card_lists) {
|
storeColumns();
|
||||||
if (card_list->set && card_list->set->game == set->game) {
|
// sort all other card lists in this window
|
||||||
card_list->ItemList::sortBy(column, ascending);
|
SetWindow* set_window = dynamic_cast<SetWindow*>(wxGetTopLevelParent(this));
|
||||||
|
if (set_window) {
|
||||||
|
for (auto card_list : set_window->getCardLists()) {
|
||||||
|
if (card_list != this) {
|
||||||
|
card_list->ItemList::sortBy(column, ascending);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,14 +286,19 @@ void CardListBase::storeColumns() {
|
|||||||
else gs.sort_cards_by = wxEmptyString;
|
else gs.sort_cards_by = wxEmptyString;
|
||||||
gs.sort_cards_ascending = sort_ascending;
|
gs.sort_cards_ascending = sort_ascending;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardListBase::selectColumns() {
|
void CardListBase::selectColumns() {
|
||||||
CardListColumnSelectDialog wnd(this, set->game);
|
CardListColumnSelectDialog wnd(this, set->game);
|
||||||
if (wnd.ShowModal() == wxID_OK) {
|
if (wnd.ShowModal() == wxID_OK) {
|
||||||
// rebuild all card lists for this game
|
|
||||||
storeColumns();
|
storeColumns();
|
||||||
FOR_EACH(card_list, card_lists) {
|
// rebuild all card lists this window
|
||||||
if (card_list->set && card_list->set->game == set->game) {
|
rebuild();
|
||||||
card_list->rebuild();
|
SetWindow* set_window = dynamic_cast<SetWindow*>(wxGetTopLevelParent(this));
|
||||||
|
if (set_window) {
|
||||||
|
for (auto card_list : set_window->getCardLists()) {
|
||||||
|
if (card_list != this) {
|
||||||
|
card_list->rebuild();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,9 +339,14 @@ void CardListBase::onColumnResize(wxListEvent& ev) {
|
|||||||
storeColumns();
|
storeColumns();
|
||||||
int col = ev.GetColumn();
|
int col = ev.GetColumn();
|
||||||
int width = GetColumnWidth(col);
|
int width = GetColumnWidth(col);
|
||||||
FOR_EACH(card_list, card_lists) {
|
// update this and all other card lists in this window
|
||||||
if (card_list != this && card_list->set && card_list->set->game == set->game) {
|
SetColumnWidth(col, width);
|
||||||
card_list->SetColumnWidth(col, width);
|
SetWindow* set_window = dynamic_cast<SetWindow*>(wxGetTopLevelParent(this));
|
||||||
|
if (set_window) {
|
||||||
|
for (auto card_list : set_window->getCardLists()) {
|
||||||
|
if (card_list != this) {
|
||||||
|
card_list->SetColumnWidth(col, width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,8 +134,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
/// Store the column sizes in the settings
|
/// Store the column sizes in the settings
|
||||||
void storeColumns();
|
void storeColumns();
|
||||||
/// All card lists; used to exchange column sizes
|
|
||||||
static vector<CardListBase*> card_lists;
|
|
||||||
|
|
||||||
// --------------------------------------------------- : Window events
|
// --------------------------------------------------- : Window events
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ protected:
|
|||||||
wxSize DoGetBestClientSize() const override;
|
wxSize DoGetBestClientSize() const override;
|
||||||
|
|
||||||
// --------------------------------------------------- : Data
|
// --------------------------------------------------- : Data
|
||||||
VoidP selected_item; ///< The currently selected item
|
VoidP selected_item; ///< The currently selected item
|
||||||
long selected_item_pos; ///< Position of the selected item in the sorted_list, or -1 if no card is selected
|
long selected_item_pos; ///< Position of the selected item in the sorted_list, or -1 if no card is selected
|
||||||
long sort_by_column; ///< Column to use for sorting, or -1 if not sorted
|
long sort_by_column; ///< Column to use for sorting, or -1 if not sorted
|
||||||
bool sort_ascending; ///< Sort order
|
bool sort_ascending; ///< Sort order
|
||||||
|
|||||||
@@ -489,3 +489,7 @@ void CardsPanel::selectFirstCard() {
|
|||||||
if (!set) return; // we want onChangeSet first
|
if (!set) return; // we want onChangeSet first
|
||||||
card_list->selectFirst();
|
card_list->selectFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardsPanel::getCardLists(vector<CardListBase*>& out) {
|
||||||
|
out.push_back(card_list);
|
||||||
|
}
|
||||||
@@ -75,6 +75,8 @@ public:
|
|||||||
void selectCard(const CardP& card) override;
|
void selectCard(const CardP& card) override;
|
||||||
void selectFirstCard() override;
|
void selectFirstCard() override;
|
||||||
|
|
||||||
|
void getCardLists(vector<CardListBase*>& out) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --------------------------------------------------- : Controls
|
// --------------------------------------------------- : Controls
|
||||||
wxSizer* s_left;
|
wxSizer* s_left;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <data/set.hpp>
|
#include <data/set.hpp>
|
||||||
#include <gui/card_select_window.hpp>
|
#include <gui/card_select_window.hpp>
|
||||||
|
|
||||||
|
class CardListBase;
|
||||||
class wxFindReplaceData;
|
class wxFindReplaceData;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SetWindowPanel
|
// ----------------------------------------------------------------------------- : SetWindowPanel
|
||||||
@@ -78,6 +79,8 @@ public:
|
|||||||
virtual void selectFirstCard() {} ///< Switch the view to the first card
|
virtual void selectFirstCard() {} ///< Switch the view to the first card
|
||||||
virtual void selectionChoices(ExportCardSelectionChoices& out) {} ///< Card subsets that can be exported from this panel
|
virtual void selectionChoices(ExportCardSelectionChoices& out) {} ///< Card subsets that can be exported from this panel
|
||||||
|
|
||||||
|
virtual void getCardLists(vector<CardListBase*>& out) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Have any controls been created?
|
/// Have any controls been created?
|
||||||
bool isInitialized() const;
|
bool isInitialized() const;
|
||||||
|
|||||||
@@ -632,6 +632,9 @@ void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RandomPackPanel::getCardLists(vector<CardListBase*>& out) {
|
||||||
|
if (isInitialized()) out.push_back(card_list);
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(RandomPackPanel, wxPanel)
|
BEGIN_EVENT_TABLE(RandomPackPanel, wxPanel)
|
||||||
EVT_CARD_SELECT(wxID_ANY, RandomPackPanel::onCardSelect)
|
EVT_CARD_SELECT(wxID_ANY, RandomPackPanel::onCardSelect)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
CardP selectedCard() const override;
|
CardP selectedCard() const override;
|
||||||
void selectCard(const CardP& card) override;
|
void selectCard(const CardP& card) override;
|
||||||
void selectionChoices(ExportCardSelectionChoices& out) override;
|
void selectionChoices(ExportCardSelectionChoices& out) override;
|
||||||
|
void getCardLists(vector<CardListBase*>& out) override;
|
||||||
|
|
||||||
// --------------------------------------------------- : Clipboard
|
// --------------------------------------------------- : Clipboard
|
||||||
|
|
||||||
|
|||||||
@@ -566,3 +566,7 @@ void StatsPanel::selectCard(const CardP& card) {
|
|||||||
card_list->setCard(card);
|
card_list->setCard(card);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatsPanel::getCardLists(vector<CardListBase*>& out) {
|
||||||
|
if (isInitialized()) out.push_back(card_list);
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
// --------------------------------------------------- : Selection
|
// --------------------------------------------------- : Selection
|
||||||
CardP selectedCard() const override;
|
CardP selectedCard() const override;
|
||||||
void selectCard(const CardP& card) override;
|
void selectCard(const CardP& card) override;
|
||||||
|
void getCardLists(vector<CardListBase*>& out) override;
|
||||||
|
|
||||||
// --------------------------------------------------- : Data
|
// --------------------------------------------------- : Data
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -388,6 +388,14 @@ void SetWindow::selectionChoices(ExportCardSelectionChoices& out) {
|
|||||||
out.push_back(make_intrusive<ExportCardSelectionChoice>()); // custom
|
out.push_back(make_intrusive<ExportCardSelectionChoice>()); // custom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<CardListBase*> SetWindow::getCardLists() {
|
||||||
|
vector<CardListBase*> out;
|
||||||
|
FOR_EACH(p, panels) {
|
||||||
|
p->getCardLists(out);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Window events - close
|
// ----------------------------------------------------------------------------- : Window events - close
|
||||||
|
|
||||||
void SetWindow::onClose(wxCloseEvent& ev) {
|
void SetWindow::onClose(wxCloseEvent& ev) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <gui/card_select_window.hpp>
|
#include <gui/card_select_window.hpp>
|
||||||
|
|
||||||
class SetWindowPanel;
|
class SetWindowPanel;
|
||||||
|
class CardListBase;
|
||||||
class wxFindDialogEvent;
|
class wxFindDialogEvent;
|
||||||
struct CardSelectEvent;
|
struct CardSelectEvent;
|
||||||
|
|
||||||
@@ -31,6 +32,9 @@ public:
|
|||||||
/// Set the icon of one of the panels
|
/// Set the icon of one of the panels
|
||||||
void setPanelIcon(SetWindowPanel* panel, wxBitmap const& icon);
|
void setPanelIcon(SetWindowPanel* panel, wxBitmap const& icon);
|
||||||
|
|
||||||
|
/// Get all card lists on all panels
|
||||||
|
vector<CardListBase*> getCardLists();
|
||||||
|
|
||||||
// --------------------------------------------------- : Set actions
|
// --------------------------------------------------- : Set actions
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user