mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 21:13:55 -07:00
Move settings cache and settings card preference provider out of libcockatrice_settings and into cockatrice
Took 52 minutes Took 9 minutes Took 1 minute
This commit is contained in:
parent
3ccb0cbb23
commit
12a2d27dfd
118 changed files with 169 additions and 134 deletions
|
|
@ -9,6 +9,8 @@ set(HEADERS
|
|||
libcockatrice/card/database/card_database_loader.h
|
||||
libcockatrice/card/database/card_database_manager.h
|
||||
libcockatrice/card/database/card_database_querier.h
|
||||
libcockatrice/card/database/interface/interface_card_preference_provider.h
|
||||
libcockatrice/card/database/interface/noop_card_preference_provider.h
|
||||
libcockatrice/card/database/parser/card_database_parser.h
|
||||
libcockatrice/card/database/parser/cockatrice_xml_3.h
|
||||
libcockatrice/card/database/parser/cockatrice_xml_4.h
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
#include "relation/card_relation.h"
|
||||
#include "set/card_set.h"
|
||||
|
||||
#include <../../../cockatrice/src/client/settings/cache_settings.h>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <algorithm>
|
||||
#include <libcockatrice/settings/cache_settings.h>
|
||||
#include <utility>
|
||||
|
||||
class CardRelation;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "parser/cockatrice_xml_3.h"
|
||||
#include "parser/cockatrice_xml_4.h"
|
||||
|
||||
#include <../../../../cockatrice/src/client/settings/cache_settings.h>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
|
@ -12,7 +13,6 @@
|
|||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <algorithm>
|
||||
#include <libcockatrice/settings/cache_settings.h>
|
||||
#include <utility>
|
||||
|
||||
CardDatabase::CardDatabase(QObject *parent, QSharedPointer<ICardPreferenceProvider> prefs)
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
#include "parser/cockatrice_xml_3.h"
|
||||
#include "parser/cockatrice_xml_4.h"
|
||||
|
||||
#include <../../../../cockatrice/src/client/settings/cache_settings.h>
|
||||
#include <QDebug>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QTime>
|
||||
#include <libcockatrice/settings/cache_settings.h>
|
||||
|
||||
CardDatabaseLoader::CardDatabaseLoader(QObject *parent, CardDatabase *db) : QObject(parent), database(db)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
#include "card_database_manager.h"
|
||||
|
||||
QSharedPointer<ICardPreferenceProvider> CardDatabaseManager::cardPreferenceProvider =
|
||||
QSharedPointer<NoopCardPreferenceProvider>::create();
|
||||
|
||||
void CardDatabaseManager::setCardPreferenceProvider(QSharedPointer<ICardPreferenceProvider> provider)
|
||||
{
|
||||
cardPreferenceProvider = provider;
|
||||
}
|
||||
|
||||
CardDatabase *CardDatabaseManager::getInstance()
|
||||
{
|
||||
static CardDatabase instance(
|
||||
nullptr, QSharedPointer<SettingsCardPreferenceProvider>::create()); // Created only once, on first access
|
||||
static CardDatabase instance(nullptr, cardPreferenceProvider);
|
||||
return &instance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ public:
|
|||
CardDatabaseManager(const CardDatabaseManager &) = delete;
|
||||
CardDatabaseManager &operator=(const CardDatabaseManager &) = delete;
|
||||
|
||||
// To be called once, before instantiation of the manager
|
||||
static void setCardPreferenceProvider(QSharedPointer<ICardPreferenceProvider> provider);
|
||||
|
||||
// Static method to access the singleton instance
|
||||
static CardDatabase *getInstance();
|
||||
static CardDatabaseQuerier *query();
|
||||
|
|
@ -24,6 +27,7 @@ public:
|
|||
private:
|
||||
CardDatabaseManager() = default; // Private constructor
|
||||
~CardDatabaseManager() = default;
|
||||
static QSharedPointer<ICardPreferenceProvider> cardPreferenceProvider;
|
||||
};
|
||||
|
||||
#endif // CARD_DATABASE_ACCESSOR_H
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "card_database_querier.h"
|
||||
|
||||
#include "../../../../cockatrice/src/database/interface/settings_card_preference_provider.h"
|
||||
#include "../card_info.h"
|
||||
#include "../printing/exact_card.h"
|
||||
#include "../set/card_set_comparator.h"
|
||||
#include "card_database.h"
|
||||
#include "interface/settings_card_preference_provider.h"
|
||||
|
||||
#include <qrandom.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#ifndef COCKATRICE_CARD_DATABASE_QUERIER_H
|
||||
#define COCKATRICE_CARD_DATABASE_QUERIER_H
|
||||
|
||||
#include "../../../../cockatrice/src/database/interface/settings_card_preference_provider.h"
|
||||
#include "../card_info.h"
|
||||
#include "../printing/exact_card.h"
|
||||
#include "interface/interface_card_preference_provider.h"
|
||||
#include "interface/settings_card_preference_provider.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <libcockatrice/utility/card_ref.h>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef COCKATRICE_INTERFACE_CARD_PREFERENCE_PROVIDER_H
|
||||
#define COCKATRICE_INTERFACE_CARD_PREFERENCE_PROVIDER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class ICardPreferenceProvider
|
||||
{
|
||||
public:
|
||||
virtual ~ICardPreferenceProvider() = default;
|
||||
virtual QString getCardPreferenceOverride(const QString &cardName) const = 0;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_INTERFACE_CARD_PREFERENCE_PROVIDER_H
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef COCKATRICE_NOOP_CARD_PREFERENCE_PROVIDER_H
|
||||
#define COCKATRICE_NOOP_CARD_PREFERENCE_PROVIDER_H
|
||||
#include "interface_card_preference_provider.h"
|
||||
|
||||
class NoopCardPreferenceProvider : public ICardPreferenceProvider
|
||||
{
|
||||
public:
|
||||
QString getCardPreferenceOverride(const QString &) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_NOOP_CARD_PREFERENCE_PROVIDER_H
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QXmlStreamReader>
|
||||
#include <libcockatrice/settings/cache_settings.h>
|
||||
#include <version_string.h>
|
||||
|
||||
#define COCKATRICE_XML4_TAGNAME "cockatrice_carddatabase"
|
||||
|
|
@ -132,7 +131,8 @@ QVariantHash CockatriceXml4Parser::loadCardPropertiesFromXml(QXmlStreamReader &x
|
|||
|
||||
void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
||||
{
|
||||
bool includeRebalancedCards = SettingsCache::instance().getIncludeRebalancedCards();
|
||||
bool includeRebalancedCards =
|
||||
true; // TODO: MOVE THIS OUT OF THE PARSER SettingsCache::instance().getIncludeRebalancedCards();
|
||||
while (!xml.atEnd()) {
|
||||
if (xml.readNext() == QXmlStreamReader::EndElement) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "card_set.h"
|
||||
|
||||
#include <libcockatrice/settings/cache_settings.h>
|
||||
#include <../../../../cockatrice/src/client/settings/cache_settings.h>
|
||||
|
||||
const char *CardSet::TOKENS_SETNAME = "TK";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue