refactor deck loading to new method

This commit is contained in:
RickyRister 2025-01-02 02:16:27 -08:00
parent 9ab5ebc84a
commit 42363c34bd
2 changed files with 8 additions and 3 deletions

View file

@ -294,12 +294,16 @@ void DeckViewContainer::loadLocalDeck()
if (!dialog.exec()) if (!dialog.exec())
return; return;
QString fileName = dialog.selectedFiles().at(0); loadDeckFromFile(dialog.selectedFiles().at(0));
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName); }
void DeckViewContainer::loadDeckFromFile(const QString &filePath)
{
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(filePath);
QString deckString; QString deckString;
DeckLoader deck; DeckLoader deck;
bool error = !deck.loadFromFile(fileName, fmt); bool error = !deck.loadFromFile(filePath, fmt);
if (!error) { if (!error) {
deckString = deck.writeToString_Native(); deckString = deck.writeToString_Native();
error = deckString.length() > MAX_FILE_LENGTH; error = deckString.length() > MAX_FILE_LENGTH;

View file

@ -112,6 +112,7 @@ public:
void setReadyStart(bool ready); void setReadyStart(bool ready);
void setSideboardLocked(bool locked); void setSideboardLocked(bool locked);
void setDeck(const DeckLoader &deck); void setDeck(const DeckLoader &deck);
void loadDeckFromFile(const QString &filePath);
}; };
class TabGame : public Tab class TabGame : public Tab