diff options
| author | 2019-03-23 01:15:02 +0100 | |
|---|---|---|
| committer | 2019-03-23 01:15:02 +0100 | |
| commit | d0f326f7289add5d84c662c6c813f1c3c88fca4f (patch) | |
| tree | b4eef57399baee34b8e349abb3f0f1ea390360b8 /cli/main.cpp | |
| parent | 489661ca4599a84033a57a5645e150e4129a70a0 (diff) | |
| download | OneRoll-d0f326f7289add5d84c662c6c813f1c3c88fca4f.tar.gz OneRoll-d0f326f7289add5d84c662c6c813f1c3c88fca4f.zip | |
Add color management for every dice.
Diffstat (limited to 'cli/main.cpp')
| -rw-r--r-- | cli/main.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index e261d63..1a2f56a 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -112,14 +112,7 @@ QString diceToMarkdown(QJsonArray array, bool withColor, bool allSameColor, bool return result.join(' '); } } -#ifdef PAINTER_OP -void displayImage(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString comment, - bool allSameFaceCount, bool allSameColor) -{ - out << DisplayToolBox::makeImage( - scalarText, resultStr, array, withColor, cmd, comment, allSameFaceCount, allSameColor); -} -#endif + void displayJSon(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { @@ -170,7 +163,7 @@ void displayMarkdown(QString scalarText, QString resultStr, QJsonArray array, bo str.append(QStringLiteral("```")); out << str; } -void displaySVG(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, +QString displaySVG(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { QString str( @@ -200,19 +193,21 @@ void displaySVG(QString scalarText, QString resultStr, QJsonArray array, bool wi if(resultStr.isEmpty()) { if(withColor) - str.append(QStringLiteral( - "<text font-size=\"16\" x=\"0\" y=\"%4\"><tspan fill=\"red\">%1</tspan> details:[%3 (%2)]</text>") + str.append(QStringLiteral("<text font-size=\"16\" x=\"0\" y=\"%4\"><tspan fill=\"red\">%1</tspan>\n" + "<tspan x=\"0\" y=\"%5\">details:</tspan>[%3 (%2)]</text>") .arg(scalarText) .arg(diceList) .arg(cmd) - .arg(y)); + .arg(y) + .arg(y * 2)); else - str.append( - QStringLiteral("<text font-size=\"16\" x=\"0\" y=\"%4\"><tspan>%1</tspan> details:[%3 (%2)]</text>") - .arg(scalarText) - .arg(diceList) - .arg(cmd) - .arg(y)); + str.append(QStringLiteral("<text font-size=\"16\" x=\"0\" y=\"%4\"><tspan>%1</tspan>\n" + "<tspan x=\"0\" y=\"%5\">details:</tspan>[%3 (%2)]</text>") + .arg(scalarText) + .arg(diceList) + .arg(cmd) + .arg(y) + .arg(y * 2)); } else if(!resultStr.isEmpty()) { @@ -221,9 +216,19 @@ void displaySVG(QString scalarText, QString resultStr, QJsonArray array, bool wi } } str.append(QStringLiteral("</svg>\n")); - out << str << "\n"; + return str; } +#ifdef PAINTER_OP +void displayImage(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, + QString warning, QString comment, bool allSameFaceCount, bool allSameColor) +{ + auto svg= displaySVG( + scalarText, resultStr, array, withColor, cmd, error, warning, comment, allSameFaceCount, allSameColor); + out << DisplayToolBox::makeImage(svg.toUtf8()); +} +#endif + void displayCommandResult(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { @@ -399,8 +404,9 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR allSameFaceCount, allSameColor); break; case SVG: - displaySVG(scalarText, resultStr, array, withColor, cmdRework, error, warnings, comment, - allSameFaceCount, allSameColor); + out << displaySVG(scalarText, resultStr, array, withColor, cmdRework, error, warnings, comment, + allSameFaceCount, allSameColor) + << "\n"; break; case BOT: case MARKDOWN: @@ -413,8 +419,8 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR break; #ifdef PAINTER_OP case IMAGE: - displayImage( - scalarText, resultStr, array, withColor, cmdRework, comment, allSameFaceCount, allSameColor); + displayImage(scalarText, resultStr, array, withColor, cmdRework, error, warnings, comment, + allSameFaceCount, allSameColor); break; #endif } |