From d0f326f7289add5d84c662c6c813f1c3c88fca4f Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 23 Mar 2019 01:15:02 +0100 Subject: Add color management for every dice. --- cli/main.cpp | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'cli/main.cpp') 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( - "%1 details:[%3 (%2)]") + str.append(QStringLiteral("%1\n" + "details:[%3 (%2)]") .arg(scalarText) .arg(diceList) .arg(cmd) - .arg(y)); + .arg(y) + .arg(y * 2)); else - str.append( - QStringLiteral("%1 details:[%3 (%2)]") - .arg(scalarText) - .arg(diceList) - .arg(cmd) - .arg(y)); + str.append(QStringLiteral("%1\n" + "details:[%3 (%2)]") + .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("\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 } -- cgit v1.2.3-70-g09d2