mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
almost finished pre-game deck loading
This commit is contained in:
parent
8dcf81654e
commit
cf21528a69
16 changed files with 140 additions and 64 deletions
29
cockatrice/src/deck_picturecacher.cpp
Normal file
29
cockatrice/src/deck_picturecacher.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <QProgressDialog>
|
||||
#include "deck_picturecacher.h"
|
||||
#include "decklist.h"
|
||||
#include "carddatabase.h"
|
||||
#include "main.h"
|
||||
|
||||
void Deck_PictureCacher::cacheHelper(InnerDecklistNode *item, QProgressDialog *progress)
|
||||
{
|
||||
for (int i = 0; i < item->size(); i++) {
|
||||
DecklistCardNode *node = dynamic_cast<DecklistCardNode *>(item->at(i));
|
||||
if (node) {
|
||||
db->getCard(node->getName())->loadPixmap();
|
||||
progress->setValue(progress->value() + 1);
|
||||
} else
|
||||
cacheHelper(dynamic_cast<InnerDecklistNode *>(item->at(i)), progress);
|
||||
}
|
||||
}
|
||||
|
||||
void Deck_PictureCacher::cachePictures(DeckList *deck, QWidget *parent)
|
||||
{
|
||||
int totalCards = deck->getRoot()->recursiveCount();
|
||||
|
||||
QProgressDialog progress(tr("Caching card pictures..."), QString(), 0, totalCards, parent);
|
||||
progress.setMinimumDuration(1000);
|
||||
progress.setWindowModality(Qt::WindowModal);
|
||||
|
||||
cacheHelper(deck->getRoot(), &progress);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue