mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 09:33:57 -07:00
add reload to DeckLoader
This commit is contained in:
parent
d9b9c79112
commit
11391a1a21
2 changed files with 23 additions and 0 deletions
|
|
@ -91,6 +91,22 @@ void DeckLoader::loadFromFileAsync(const QString &fileName, DeckFileFormat::Form
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeckLoader::reload()
|
||||||
|
{
|
||||||
|
QString lastFileName = loadedDeck.lastLoadInfo.fileName;
|
||||||
|
if (lastFileName.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::optional<LoadedDeck> deck = loadFromFile(lastFileName, loadedDeck.lastLoadInfo.fileFormat, false);
|
||||||
|
|
||||||
|
if (!deck) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedDeck = *deck;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LoadedDeck> DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId)
|
std::optional<LoadedDeck> DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId)
|
||||||
{
|
{
|
||||||
DeckList deckList;
|
DeckList deckList;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void loadFromFileAsync(const QString &fileName, DeckFileFormat::Format fmt, bool userRequest);
|
void loadFromFileAsync(const QString &fileName, DeckFileFormat::Format fmt, bool userRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 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.
|
||||||
|
* @return Whether the loaded succeeded.
|
||||||
|
*/
|
||||||
|
bool reload();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Loads a deck from a local file.
|
* @brief Loads a deck from a local file.
|
||||||
* @param fileName The file to load
|
* @param fileName The file to load
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue