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())
return;
QString fileName = dialog.selectedFiles().at(0);
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
loadDeckFromFile(dialog.selectedFiles().at(0));
}
void DeckViewContainer::loadDeckFromFile(const QString &filePath)
{
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(filePath);
QString deckString;
DeckLoader deck;
bool error = !deck.loadFromFile(fileName, fmt);
bool error = !deck.loadFromFile(filePath, fmt);
if (!error) {
deckString = deck.writeToString_Native();
error = deckString.length() > MAX_FILE_LENGTH;

View file

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