aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/CMakeLists.txt47
-rw-r--r--cli/cmds.txt47
-rw-r--r--cli/dice.qrc0
-rw-r--r--cli/i18n/dice_en.ts74
-rw-r--r--cli/i18n/dice_fr.ts75
-rw-r--r--cli/main.cpp22
-rwxr-xr-xcli/test_dice.sh8
7 files changed, 259 insertions, 14 deletions
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index 9497b41..680d1b8 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 2.8)
+option(UPDATE_TRANSLATIONS "update Translation" OFF)
+MESSAGE(STATUS "UPDATE TRANSLATIONS: ${UPDATE_TRANSLATIONS}")
+
project(dice)
+
+
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
@@ -12,19 +17,48 @@ find_package(Qt5Core)
set(EXECUTABLE_OUTPUT_PATH bin/)
-
include_directories(${Qt5Core_INCLUDES} ../)
add_definitions(${Qt5Core_DEFINITIONS})
set(MODE "cli")
-
ADD_DEFINITIONS(
-std=c++11 # Or -std=c++0x
# Other flags
)
-add_executable(
- dice
+
+set(dice_RESOURCES diceparser.qrc)
+FIND_PACKAGE(Qt5LinguistTools)
+
+
+IF(UPDATE_TRANSLATIONS)
+ MESSAGE( update Translation )
+ FILE(GLOB_RECURSE translate_dice_SRCS ../*.cpp ../*.h)
+ SET(translate_SRCS ${translate_dice_SRCS})
+ SET(dice_TS "${CMAKE_CURRENT_SOURCE_DIR}/i18n/dice_en.ts" "${CMAKE_CURRENT_SOURCE_DIR}/i18n/dice_fr.ts")
+ELSE()
+ MESSAGE( NO updates for translations)
+ FILE(GLOB dice_TS "${CMAKE_CURRENT_SOURCE_DIR}/i18n/*.ts")
+ENDIF(UPDATE_TRANSLATIONS)
+
+if(Qt5Core_FOUND)
+
+ IF(UPDATE_TRANSLATIONS)
+ MESSAGE(status "find" ${dice_TS} ${translate_SRCS} )
+ QT5_CREATE_TRANSLATION(dice_QM ${translate_SRCS} ${dice_TS})
+ ELSE()
+ QT5_ADD_TRANSLATION(dice_QM ${dice_TS})
+ ENDIF()
+
+ QT5_ADD_RESOURCES(dice_RESOURCES_RCC ${dice_RESOURCES})
+
+ # guess plugins and libraries directory
+ set(QT_PLUGINS_DIR "${Qt5Core_DIR}/../../../plugins")
+ get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
+ get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
+endif()
+
+SET( dice_sources
../diceparser.cpp
../range.cpp
../booleancondition.cpp
@@ -58,10 +92,11 @@ add_executable(
../node/ifnode.cpp
main.cpp
../highlightdice.cpp
- )
+)
+
+add_executable( dice ${dice_sources} ${dice_QM} )
target_link_libraries(dice ${Qt5Core_LIBRARIES})
INSTALL_TARGETS(/bin dice)
#qt5_use_modules()
-
diff --git a/cli/cmds.txt b/cli/cmds.txt
new file mode 100644
index 0000000..dfa4b26
--- /dev/null
+++ b/cli/cmds.txt
@@ -0,0 +1,47 @@
+1L[cheminée,chocolat,épée,arc,chute_de_pierre]
+10d10c[>=6]-@c[=1]
+10d10c[>=6]-@c[=1]-@c[=1]
+10d10c[>6]+@c[=10]
+1+1D10
+3d10c[>=5]
+3nwod
+1+(4*3)D10
+2+4/4
+2D10*2D20*8
+1+(4*3)D10
+(4D6)D10
+1D100a[>=95]a[>=96]a[>=97]a[>=98]a[>=99]e[>=100]
+3D100
+4k3
+10D10e[>=6]sc[>=6]
+10D10e10s
+10D10s
+15D10e10c[8-10]
+10d10e11
+1D8+2D6+7
+D25
+1L[tete[10],ventre[50],jambe[40]]
+2d6c[%2=0]
+D25+D10
+D25;D10
+8+8+8
+1D20-88
+100*1D20*2D6
+100/28*3
+100/8
+100*3*8
+help
+la
+10D10c[<2|>7]
+1L[tete,bras_droit,bras_gauche,jambe_droite,jambe_gauche,ventre[6-7],buste[8-10]]
+10D6c[=2|=4|=6]
+10D10e[=1|=10]k4
+10+10s
+1d6e6;1d4e4mk1
+1d6e6;1d4e4mk1
+1d100e[>=95]i[<5]{-1d100e95}
+100*3*8
+1d100i[<70]{1d10i[=10]{1d100i[<70]{1d10e10}}}
+10d[-8--1]
+4d6p[4:black]c[>=4]+1d6p[1:white]c6-@c1+1d6p[1:red]c[>=4]+@c6-@c1
+10d[0-9]
diff --git a/cli/dice.qrc b/cli/dice.qrc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cli/dice.qrc
diff --git a/cli/i18n/dice_en.ts b/cli/i18n/dice_en.ts
new file mode 100644
index 0000000..3efc610
--- /dev/null
+++ b/cli/i18n/dice_en.ts
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="en_US">
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../../diceparser.cpp" line="186"/>
+ <source>Nothing was understood</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="603"/>
+ <source>Dice with %1 face(s) does not exist. Please, put a value higher than 0</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="648"/>
+ <source>List is missing after the L operator. Please, add it (e.g : 1L[sword,spear,gun,arrow])</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="905"/>
+ <source>Validator is missing after the c operator. Please, change it</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="931"/>
+ <source>Validator is missing after the %1 operator. Please, change it</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="943"/>
+ <source>This condition %1 introduces an endless loop. Please, change it</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="954"/>
+ <source>Validator is missing after the e operator. Please, change it</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/keepdiceexecnode.cpp" line="48"/>
+ <source> You ask to keep %1 dice but the result only has %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/listaliasnode.cpp" line="55"/>
+ <source>List of Alias:
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/helpnode.cpp" line="37"/>
+ <source>Rolisteam Dice Parser:
+Full documentation at: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/jumpbackwardnode.cpp" line="75"/>
+ <source> The @ operator expects dice result. Please check the documentation to fix your command.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/dicerollernode.cpp" line="30"/>
+ <source>No dice to roll</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../node/scalaroperatornode.cpp" line="128"/>
+ <source>Division by zero</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/cli/i18n/dice_fr.ts b/cli/i18n/dice_fr.ts
new file mode 100644
index 0000000..438e99b
--- /dev/null
+++ b/cli/i18n/dice_fr.ts
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="fr_FR">
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../../diceparser.cpp" line="186"/>
+ <source>Nothing was understood</source>
+ <translation>Rien n&apos;a été compris</translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="603"/>
+ <source>Dice with %1 face(s) does not exist. Please, put a value higher than 0</source>
+ <translation>Dés avec %1 face(s) n&apos;existe pas. Si vous plait, demander une valeur supérieure à 0</translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="648"/>
+ <source>List is missing after the L operator. Please, add it (e.g : 1L[sword,spear,gun,arrow])</source>
+ <translation>Liste manquante après l&apos;operateur L. Veuillez l&apos;ajouter (e.g : 1L[épée,lance,flingue,flèche]) </translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="905"/>
+ <source>Validator is missing after the c operator. Please, change it</source>
+ <translation>Validateur est manquant après l&apos;opérateur c, veuillez le définir</translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="931"/>
+ <source>Validator is missing after the %1 operator. Please, change it</source>
+ <translation>Validateur est manquant après l&apos;opérateur %1, veuillez le définir</translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="943"/>
+ <source>This condition %1 introduces an endless loop. Please, change it</source>
+ <translation>La condition %1 introduit une boucle infinie. Veuillez la changer</translation>
+ </message>
+ <message>
+ <location filename="../../diceparser.cpp" line="954"/>
+ <source>Validator is missing after the e operator. Please, change it</source>
+ <translation>Validateur est manquant après l&apos;opérateur e, veuillez le définir</translation>
+ </message>
+ <message>
+ <location filename="../../node/keepdiceexecnode.cpp" line="48"/>
+ <source> You ask to keep %1 dice but the result only has %2</source>
+ <translation>Vous souhaitez garder %1 dés mais le resultat n&apos;a seulement que %2 dés</translation>
+ </message>
+ <message>
+ <location filename="../../node/listaliasnode.cpp" line="55"/>
+ <source>List of Alias:
+</source>
+ <translation>Liste d&apos;alias:</translation>
+ </message>
+ <message>
+ <location filename="../../node/helpnode.cpp" line="37"/>
+ <source>Rolisteam Dice Parser:
+Full documentation at: %1</source>
+ <translation>Rolisteam Dice Parser:
+Documentation complète sur: %1</translation>
+ </message>
+ <message>
+ <location filename="../../node/jumpbackwardnode.cpp" line="75"/>
+ <source> The @ operator expects dice result. Please check the documentation to fix your command.</source>
+ <translation>L&apos;opérateur @ attend un résultat de dés. Veuillez vérifier la documentation pour réparer votre commande.</translation>
+ </message>
+ <message>
+ <location filename="../../node/dicerollernode.cpp" line="30"/>
+ <source>No dice to roll</source>
+ <translation>Aucun dé à lancer</translation>
+ </message>
+ <message>
+ <location filename="../../node/scalaroperatornode.cpp" line="128"/>
+ <source>Division by zero</source>
+ <translation>Division par zéro</translation>
+ </message>
+</context>
+</TS>
diff --git a/cli/main.cpp b/cli/main.cpp
index 21bb1ca..7a5ed97 100644
--- a/cli/main.cpp
+++ b/cli/main.cpp
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2014 by Renaud Guezennec *
-* http://renaudguezennec.homelinux.org/accueil,3.html *
+* http://www.rolisteam.org/contact *
* *
* This file is part of DiceParser *
* *
@@ -77,6 +77,14 @@ QString diceToText(ExportedDiceResult& dice,bool highlight,bool homogeneous)
{
prefix = "\e[34m%1\e[0m";
}
+ if(tmp.getColor()=="red")
+ {
+ prefix = "\e[31m%1\e[0m";
+ }
+ if(tmp.getColor()=="black")
+ {
+ prefix = "\e[30m%1\e[0m";
+ }
}
if(i==0)
@@ -116,8 +124,7 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight)
if(parser->parseLine(cmd))
{
//
- if(treeFile.isEmpty())
- {
+
parser->Start();
if(!parser->getErrorMap().isEmpty())
{
@@ -150,11 +157,10 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight)
str = parser->getStringResult();
}
out << str << "\n";
- }
- else
- {
- parser->writeDownDotTree(treeFile);
- }
+ if(!treeFile.isEmpty())
+ {
+ parser->writeDownDotTree(treeFile);
+ }
}
else
{
diff --git a/cli/test_dice.sh b/cli/test_dice.sh
new file mode 100755
index 0000000..bd20b6a
--- /dev/null
+++ b/cli/test_dice.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+export LD_LIBRARY_PATH="/home/renaud/application/other/Qt/5.7/gcc_64/lib:$LD_LIBRARY_PATH"
+for line in `cat cmds.txt`
+do
+ #echo $line;
+ dice $line
+done