diff options
| author | 2015-12-24 11:20:57 +0100 | |
|---|---|---|
| committer | 2015-12-24 11:20:57 +0100 | |
| commit | 0332e66a2ff0fed8a307d2ec1deddaf4dc00c75e (patch) | |
| tree | 291b875fc1522a986b240ef8a3830a97239cd713 /cli | |
| parent | 536ba83d1ee1daf44f8c7d5f67fb55dcce696743 (diff) | |
| download | OneRoll-0332e66a2ff0fed8a307d2ec1deddaf4dc00c75e.tar.gz OneRoll-0332e66a2ff0fed8a307d2ec1deddaf4dc00c75e.zip | |
Start modification for the display function when displaying result.
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/main.cpp | 128 |
1 files changed, 88 insertions, 40 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index 9a966ba..80c19a9 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -43,56 +43,103 @@ QTextStream out(stdout, QIODevice::WriteOnly); -QString diceToText(ExportedDiceResult& dice,bool highlight) +QString diceToText(ExportedDiceResult& dice,bool highlight,bool homogeneous) { QStringList resultGlobal; - foreach(int face, dice.keys()) + if(homogeneous) { - QStringList result; - ListDiceResult diceResult = dice.value(face); - //patternColor = patternColorarg(); - foreach (DiceAndHighlight tmp, diceResult) - { - QStringList diceListStr; - QStringList diceListChildren; - + foreach(int face, dice.keys()) + { + QStringList result; + ListDiceResult diceResult = dice.value(face); + //patternColor = patternColorarg(); + foreach (DiceAndHighlight tmp, diceResult) + { + QStringList diceListStr; + QStringList diceListChildren; - for(int i =0; i < tmp.first.size(); ++i) - { - qint64 dievalue = tmp.first[i]; - QString prefix("%1"); - if((tmp.second)&&(highlight)) + for(int i =0; i < tmp.first.size(); ++i) + { + qint64 dievalue = tmp.first[i]; + QString prefix("%1"); + + if((tmp.second)&&(highlight)) + { + prefix = "\e[0;31m%1\e[0m"; + } + + if(i==0) + { + diceListStr << prefix.arg(QString::number(dievalue)); + } + else + { + diceListChildren << prefix.arg(QString::number(dievalue)); + } + } + if(!diceListChildren.isEmpty()) { - prefix = "\e[0;31m%1\e[0m"; + diceListStr << QString("[%1]").arg(diceListChildren.join(' ')); } - if(i==0) + result << diceListStr.join(' '); + // qDebug() << result << tmp.first << tmp.second; + } + + if(dice.keys().size()>1) + { + resultGlobal << QString(" d%2:(%1)").arg(result.join(',')).arg(face); + } + else + { + resultGlobal << result; + } + } + } + else + { + foreach(int face, dice.keys()) + { + QStringList result; + ListDiceResult diceResult = dice.value(face); + foreach (DiceAndHighlight tmp, diceResult) + { + QStringList diceListStr; + QStringList diceListChildren; + + + for(int i =0; i < tmp.first.size(); ++i) { - diceListStr << prefix.arg(QString::number(dievalue)); + qint64 dievalue = tmp.first[i]; + QString prefix("%1"); + + if((tmp.second)&&(highlight)) + { + prefix = "\e[0;31m%1\e[0m"; + } + + if(i==0) + { + diceListStr << prefix.arg(QString::number(dievalue)); + } + else + { + diceListChildren << prefix.arg(QString::number(dievalue)); + } } - else + if(!diceListChildren.isEmpty()) { - diceListChildren << prefix.arg(QString::number(dievalue)); + diceListStr << QString("[%1]").arg(diceListChildren.join(' ')); } - } - if(!diceListChildren.isEmpty()) - { - diceListStr << QString("[%1]").arg(diceListChildren.join(' ')); - } - - result << diceListStr.join(' '); - // qDebug() << result << tmp.first << tmp.second; - } - - if(dice.keys().size()>1) - { - resultGlobal << QString(" d%2:(%1)").arg(result.join(',')).arg(face); - } - else - { - resultGlobal << result; - } + + result << diceListStr.join(' '); + // qDebug() << result << tmp.first << tmp.second; + } + + resultGlobal << QString(" (%1) ").arg(result.join(',')); + + } } return resultGlobal.join(' '); } @@ -114,8 +161,9 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) } ExportedDiceResult list; - parser->getLastDiceResult(list); - QString diceText = diceToText(list,highlight); + bool homogeneous; + parser->getLastDiceResult(list,homogeneous); + QString diceText = diceToText(list,highlight,homogeneous); QString scalarText; QString str; |