![]() |
Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
|
#include <deck_loader.h>
Public Types | |
| enum | DecklistWebsite { DecklistOrg , DecklistXyz } |
Signals | |
| void | loadFinished (bool success) |
Public Member Functions | |
| DeckLoader (QObject *parent) | |
| DeckLoader (const DeckLoader &)=delete | |
| DeckLoader & | operator= (const DeckLoader &)=delete |
| bool | hasNotBeenLoaded () const |
| void | loadFromFileAsync (const QString &fileName, DeckFileFormat::Format fmt, bool userRequest) |
| Asynchronously loads a deck from a local file into this DeckLoader. The loadFinished signal will be emitted when the load finishes. Once the loading finishes, the deck can be accessed with getDeck. | |
| bool | reload () |
| Loads the file that the lastLoadInfo currently points to into this instance. No-ops if the lastLoadInfo is missing the required info or the load fails. | |
| LoadedDeck & | getDeck () |
| const LoadedDeck & | getDeck () const |
| void | setDeck (const LoadedDeck &deck) |
Static Public Member Functions | |
| static std::optional< LoadedDeck > | loadFromFile (const QString &fileName, DeckFileFormat::Format fmt, bool userRequest=false) |
| Loads a deck from a local file. | |
| static std::optional< LoadedDeck > | loadFromRemote (const QString &nativeString, int remoteDeckId) |
| Loads a deck from the response of a remote deck request. | |
| static std::optional< LoadedDeck::LoadInfo > | saveToFile (const DeckList &deck, const QString &fileName, DeckFileFormat::Format fmt) |
| Saves a DeckList to a local file. | |
| static bool | saveToFile (const LoadedDeck &deck) |
| Saves a LoadedDeck to a local file. Uses the lastLoadInfo in the LoadedDeck to determine where to save to. | |
| static bool | saveToNewFile (LoadedDeck &deck, const QString &fileName, DeckFileFormat::Format fmt) |
| Saves a LoadedDeck to a new local file. | |
| static QString | exportDeckToDecklist (const DeckList &deckList, DecklistWebsite website) |
| static void | saveToClipboard (const DeckList &deckList, bool addComments=true, bool addSetNameAndNumber=true) |
| static bool | saveToStream_Plain (QTextStream &out, const DeckList &deckList, bool addComments=true, bool addSetNameAndNumber=true) |
| static void | printDeckList (QPrinter *printer, const DeckList &deckList) |
| Prints the decklist to the provided QPrinter. | |
| static bool | convertToCockatriceFormat (LoadedDeck &deck) |
Static Public Attributes | |
| static const QStringList | ACCEPTED_FILE_EXTENSIONS = {"*.cod", "*.dec", "*.dek", "*.txt", "*.mwDeck"} |
| static const QStringList | FILE_NAME_FILTERS |
Static Private Member Functions | |
| static bool | updateLastLoadedTimestamp (LoadedDeck &deck) |
| Updates the lastLoadedTimestamp field in the file corresponding to the deck, without changing the FileModificationTime of the file. | |
| static void | printDeckListNode (QTextCursor *cursor, const InnerDecklistNode *node) |
| static void | saveToStream_DeckHeader (QTextStream &out, const DeckList &deckList) |
| static void | saveToStream_DeckZone (QTextStream &out, const InnerDecklistNode *zoneNode, bool addComments=true, bool addSetNameAndNumber=true, const QString &boardZoneName=QString()) |
| static void | saveToStream_DeckZoneCards (QTextStream &out, QList< DecklistCardNode * > cards, bool addComments=true, bool addSetNameAndNumber=true, const QString &boardZoneName=QString()) |
Private Attributes | |
| LoadedDeck | loadedDeck |
| DeckLoader::DeckLoader | ( | QObject * | parent | ) |
|
delete |
|
static |
Converts the given deck's file to the Cockatrice file format. Uses the lastLoadInfo in the LoadedDeck to determine the current name of the file and where to save to.
| deck | The deck to convert. Should have valid lastLoadInfo. Will update the lastLoadInfo. |
|
static |
Export deck to decklist function, called to format the deck in a way to be sent to a server
| deckList | The decklist to export |
| website | The website we're sending the deck to |
|
inline |
|
inline |
|
inlinenodiscard |
|
signal |
|
static |
Loads a deck from a local file.
| fileName | The file to load |
| fmt | The format of the file to load |
| userRequest | Whether the load was manually requested by the user, instead of being done in the background. |
| void DeckLoader::loadFromFileAsync | ( | const QString & | fileName, |
| DeckFileFormat::Format | fmt, | ||
| bool | userRequest ) |
Asynchronously loads a deck from a local file into this DeckLoader. The loadFinished signal will be emitted when the load finishes. Once the loading finishes, the deck can be accessed with getDeck.
| fileName | The file to load |
| fmt | The format of the file to load |
| userRequest | Whether the load was manually requested by the user, instead of being done in the background. |
|
static |
Loads a deck from the response of a remote deck request.
| nativeString | The deck string, in cod format |
| remoteDeckId | The remote deck id |
|
delete |
|
static |
Prints the decklist to the provided QPrinter.
| printer | The printer to render the decklist to. |
| deckList |
|
staticprivate |
| bool DeckLoader::reload | ( | ) |
Loads the file that the lastLoadInfo currently points to into this instance. No-ops if the lastLoadInfo is missing the required info or the load fails.
|
static |
|
static |
|
static |
Saves a LoadedDeck to a local file. Uses the lastLoadInfo in the LoadedDeck to determine where to save to.
| deck | The LoadedDeck to save. Should have valid lastLoadInfo. |
|
static |
Saves a LoadedDeck to a new local file.
| deck | The LoadedDeck to save. Will update the lastLoadInfo. |
| fileName | The file to write to |
| fmt | The deck file format to use |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
static |
|
inline |
|
staticprivate |
Updates the lastLoadedTimestamp field in the file corresponding to the deck, without changing the FileModificationTime of the file.
|
static |
Supported file extensions for decklist files
|
static |
For use with QFileDialog::setNameFilters
|
private |