mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Move LoadedDeck and DeckFileFormat data types into libcockatrice_deck_list
This commit is contained in:
parent
7c4c541a81
commit
7a894df554
13 changed files with 24 additions and 8 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include <QString>
|
||||
#include <functional>
|
||||
#include <libcockatrice/card/card_localization.h>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
|
||||
struct CardSearchLanguage;
|
||||
struct LoadedDeck;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
|
||||
#include "../board/arrow_data.h"
|
||||
#include "../board/counter_state.h"
|
||||
#include "../zones/card_zone_logic.h"
|
||||
#include "../zones/hand_zone_logic.h"
|
||||
#include "../zones/pile_zone_logic.h"
|
||||
|
|
@ -22,6 +24,11 @@
|
|||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <libcockatrice/filters/filter_string.h>
|
||||
#include <libcockatrice/protocol/pb/card_attributes.pb.h>
|
||||
#include <libcockatrice/protocol/pb/game_event.pb.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#include "deck_file_format.h"
|
||||
|
||||
#include <qnamespace.h>
|
||||
|
||||
DeckFileFormat::Format DeckFileFormat::getFormatFromName(const QString &fileName)
|
||||
{
|
||||
if (fileName.endsWith(".cod", Qt::CaseInsensitive)) {
|
||||
return Cockatrice;
|
||||
}
|
||||
return PlainText;
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef COCKATRICE_DECK_FILE_FORMAT_H
|
||||
#define COCKATRICE_DECK_FILE_FORMAT_H
|
||||
#include <QString>
|
||||
|
||||
namespace DeckFileFormat
|
||||
{
|
||||
|
||||
/**
|
||||
* The deck file formats that Cockatrice supports.
|
||||
*/
|
||||
enum Format
|
||||
{
|
||||
/**
|
||||
* Plaintext deck files, a format that is intended to be widely supported among different programs.
|
||||
* This format does not support Cockatrice specific features such as banner cards or tags.
|
||||
*/
|
||||
PlainText,
|
||||
|
||||
/**
|
||||
* This is Cockatrice's native deck file format, and supports deck metadata such as banner cards and tags.
|
||||
* Stored as .cod files.
|
||||
*/
|
||||
Cockatrice
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines what deck file format the given filename corresponds to.
|
||||
*
|
||||
* @param fileName The filename
|
||||
* @return The deck format
|
||||
*/
|
||||
Format getFormatFromName(const QString &fileName);
|
||||
|
||||
} // namespace DeckFileFormat
|
||||
|
||||
#endif // COCKATRICE_DECK_FILE_FORMAT_H
|
||||
|
|
@ -7,13 +7,14 @@
|
|||
#ifndef DECK_LOADER_H
|
||||
#define DECK_LOADER_H
|
||||
|
||||
#include "deck_file_format.h"
|
||||
#include "loaded_deck.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QObject>
|
||||
#include <QPrinter>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTextCursor>
|
||||
#include <libcockatrice/deck_list/deck_list.h>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <optional>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#include "loaded_deck.h"
|
||||
|
||||
bool LoadedDeck::LoadInfo::isEmpty() const
|
||||
{
|
||||
return fileName.isEmpty() && remoteDeckId == NON_REMOTE_ID;
|
||||
}
|
||||
|
||||
bool LoadedDeck::isEmpty() const
|
||||
{
|
||||
return deckList.isEmpty() && lastLoadInfo.isEmpty();
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#ifndef COCKATRICE_LOADED_DECK_H
|
||||
#define COCKATRICE_LOADED_DECK_H
|
||||
|
||||
#include "deck_file_format.h"
|
||||
#include "libcockatrice/deck_list/deck_list.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* @brief Represents a deck that was loaded from somewhere.
|
||||
* Contains the DeckList itself, as well as info about where it was loaded from.
|
||||
*/
|
||||
struct LoadedDeck
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Information about where the deck was loaded from.
|
||||
*
|
||||
* For local decks, the remoteDeckId field will always be -1.
|
||||
* For remote decks, fileName will be empty and fileFormat will always be CockatriceFormat
|
||||
*/
|
||||
struct LoadInfo
|
||||
{
|
||||
static constexpr int NON_REMOTE_ID = -1;
|
||||
|
||||
QString fileName = "";
|
||||
DeckFileFormat::Format fileFormat = DeckFileFormat::Cockatrice;
|
||||
int remoteDeckId = NON_REMOTE_ID;
|
||||
|
||||
bool isEmpty() const;
|
||||
};
|
||||
|
||||
DeckList deckList; ///< The decklist itself
|
||||
LoadInfo lastLoadInfo = {}; ///< info about where the deck was loaded from
|
||||
|
||||
bool isEmpty() const;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_LOADED_DECK_H
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#include "intent_open_local_deck.h"
|
||||
|
||||
#include "../deck_loader/deck_file_format.h"
|
||||
#include "../deck_loader/deck_loader.h"
|
||||
#include "../deck_loader/loaded_deck.h"
|
||||
#include "../widgets/tabs/tab_supervisor.h"
|
||||
|
|
@ -9,6 +8,7 @@
|
|||
#include "libcockatrice/card/database/card_database_loader.h"
|
||||
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/deck_list/deck_file_format.h>
|
||||
#include <optional>
|
||||
|
||||
IntentOpenLocalDeck::IntentOpenLocalDeck(TabSupervisor *_tabSupervisor, const QString &_file)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COCKATRICE_DECK_STATE_MANAGER_H
|
||||
#define COCKATRICE_DECK_STATE_MANAGER_H
|
||||
|
||||
#include "../../deck_loader/loaded_deck.h"
|
||||
#include "deck_list_model.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QObject>
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include <QStringList>
|
||||
#include <functional>
|
||||
#include <libcockatrice/deck_list/deck_list.h>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class DeckListHistoryManager;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
|
||||
#include "libcockatrice/deck_list/deck_list.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class QPlainTextEdit;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#ifndef VISUAL_DECK_STORAGE_MODEL_H
|
||||
#define VISUAL_DECK_STORAGE_MODEL_H
|
||||
|
||||
#include "../../deck_loader/loaded_deck.h"
|
||||
#include "libcockatrice/utility/card_ref.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
|
@ -24,6 +23,9 @@
|
|||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <libcockatrice/deck_list/deck_list.h>
|
||||
#include <libcockatrice/deck_list/loaded_deck.h>
|
||||
#include <optional>
|
||||
#include <qnamespace.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue