mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
refactor deck loading to new method
This commit is contained in:
parent
9ab5ebc84a
commit
42363c34bd
2 changed files with 8 additions and 3 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue