mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-16 12:07:47 -07:00
[VDS] Reload deck on hover if file has been modified since last load (#6507)
* add reload to DeckLoader * [VDS] Reload deck on hover if file has been modified since last load * fix version incompatibility
This commit is contained in:
parent
d9b9c79112
commit
39ddaa0c35
7 changed files with 124 additions and 20 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)
|
||||
{
|
||||
DeckList deckList;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@ public:
|
|||
*/
|
||||
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.
|
||||
* @param fileName The file to load
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue