mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Analyze deck on tappedout Fix small bug in deckstats interface
This commit is contained in:
parent
680277ad6a
commit
7f28a7e844
10 changed files with 310 additions and 21 deletions
|
|
@ -514,10 +514,20 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
|
|||
bool inSideboard = false;
|
||||
|
||||
int okRows = 0;
|
||||
bool titleFound = false;
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine().simplified();
|
||||
if (line.startsWith("//"))
|
||||
{
|
||||
if(!titleFound)
|
||||
{
|
||||
name = line.mid(2).trimmed();
|
||||
titleFound = true;
|
||||
} else if(okRows == 0) {
|
||||
comments += line.mid(2).trimmed() + "\n";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
InnerDecklistNode *zone;
|
||||
if (line.startsWith("Sideboard", Qt::CaseInsensitive)) {
|
||||
|
|
@ -600,14 +610,15 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
|
|||
|
||||
struct WriteToStream {
|
||||
QTextStream &stream;
|
||||
bool prefixSideboardCards;
|
||||
|
||||
WriteToStream(QTextStream &_stream) : stream(_stream) {}
|
||||
WriteToStream(QTextStream &_stream, bool _prefixSideboardCards) : stream(_stream), prefixSideboardCards(_prefixSideboardCards) {}
|
||||
|
||||
void operator()(
|
||||
const InnerDecklistNode *node,
|
||||
const DecklistCardNode *card
|
||||
) {
|
||||
if (node->getName() == "side") {
|
||||
if (prefixSideboardCards && node->getName() == "side") {
|
||||
stream << "SB: ";
|
||||
}
|
||||
stream << QString("%1 %2\n").arg(
|
||||
|
|
@ -618,24 +629,24 @@ struct WriteToStream {
|
|||
}
|
||||
};
|
||||
|
||||
bool DeckList::saveToStream_Plain(QTextStream &out)
|
||||
bool DeckList::saveToStream_Plain(QTextStream &out, bool prefixSideboardCards)
|
||||
{
|
||||
WriteToStream writeToStream(out);
|
||||
WriteToStream writeToStream(out, prefixSideboardCards);
|
||||
forEachCard(writeToStream);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeckList::saveToFile_Plain(QIODevice *device)
|
||||
bool DeckList::saveToFile_Plain(QIODevice *device, bool prefixSideboardCards)
|
||||
{
|
||||
QTextStream out(device);
|
||||
return saveToStream_Plain(out);
|
||||
return saveToStream_Plain(out, prefixSideboardCards);
|
||||
}
|
||||
|
||||
QString DeckList::writeToString_Plain()
|
||||
QString DeckList::writeToString_Plain(bool prefixSideboardCards)
|
||||
{
|
||||
QString result;
|
||||
QTextStream out(&result);
|
||||
saveToStream_Plain(out);
|
||||
saveToStream_Plain(out, prefixSideboardCards);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue