mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
[Refactor] Move LoadedDeck and DeckFileFormat data types into libcockatrice_deck_list (#7424)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
85fd052fdb
commit
6f0c5dca12
32 changed files with 51 additions and 35 deletions
|
|
@ -7,11 +7,13 @@ set(HEADERS
|
|||
libcockatrice/deck_list/tree/abstract_deck_list_node.h
|
||||
libcockatrice/deck_list/tree/deck_list_card_node.h
|
||||
libcockatrice/deck_list/tree/inner_deck_list_node.h
|
||||
libcockatrice/deck_list/deck_file_format.h
|
||||
libcockatrice/deck_list/deck_list.h
|
||||
libcockatrice/deck_list/deck_list_history_manager.h
|
||||
libcockatrice/deck_list/deck_list_node_tree.h
|
||||
libcockatrice/deck_list/deck_list_memento.h
|
||||
libcockatrice/deck_list/deck_list_plain_text_parser.h
|
||||
libcockatrice/deck_list/loaded_deck.h
|
||||
libcockatrice/deck_list/playmat_resolver.h
|
||||
libcockatrice/deck_list/sideboard_plan.h
|
||||
)
|
||||
|
|
@ -25,10 +27,12 @@ add_library(
|
|||
libcockatrice/deck_list/tree/abstract_deck_list_node.cpp
|
||||
libcockatrice/deck_list/tree/deck_list_card_node.cpp
|
||||
libcockatrice/deck_list/tree/inner_deck_list_node.cpp
|
||||
libcockatrice/deck_list/deck_file_format.cpp
|
||||
libcockatrice/deck_list/deck_list.cpp
|
||||
libcockatrice/deck_list/deck_list_history_manager.cpp
|
||||
libcockatrice/deck_list/deck_list_node_tree.cpp
|
||||
libcockatrice/deck_list/deck_list_plain_text_parser.cpp
|
||||
libcockatrice/deck_list/loaded_deck.cpp
|
||||
libcockatrice/deck_list/playmat_resolver.cpp
|
||||
libcockatrice/deck_list/sideboard_plan.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
#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;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#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();
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue