diff --git a/data/parcours2.json b/data/parcours2.json new file mode 100644 index 0000000..6ed3056 --- /dev/null +++ b/data/parcours2.json @@ -0,0 +1,80 @@ +{ + "name": "Chemin des Saveurs", + "city": "Bourg en Bresse", + "departement": 1, + "difficulty": 3, + "duration": 3.8, + "length": 24.6, + "description": "Parcours gourmand et culturel entre ville et campagne, à la découverte des trésors cachés de Bourg en Bresse.", + "image": "data/parcours1.png", + "steps": [ + { + "numero": 1, + "title": "Départ au centre-ville", + "GPS": "N 46 12.321 E 5 13.245", + "indice": "Sous la grande horloge, cherchez la plaque dorée.", + "reponse": "Horloge", + "dialogue": [ + { + "personnage": "Clémentine", + "texte": "Bienvenue à tous, voici le centre historique !" + }, + { + "personnage": "Léo", + "texte": "Regardez cette magnifique horloge, elle date du XIXe siècle !" + } + ] + }, + { + "numero": 2, + "title": "Marché couvert", + "GPS": "N 46 12.500 E 5 13.800", + "indice": "Le nombre de colonnes à l'entrée principale vous donnera la solution.", + "reponse": 6, + "dialogue": [ + { + "personnage": "Aurélie", + "texte": "Ici, on trouve les meilleurs fromages de la région !" + }, + { + "personnage": "Sami", + "texte": "Combien de colonnes vois-tu à l'entrée ?" + } + ] + }, + { + "numero": 3, + "title": "Au bord de la Reyssouze", + "GPS": "N 46 12.900 E 5 13.900", + "indice": "Sous le vieux pont de pierre, cherchez une gravure effacée.", + "reponse": "1912", + "dialogue": [ + { + "personnage": "Juliette", + "texte": "La Reyssouze apporte de la fraîcheur en été." + }, + { + "personnage": "Marc", + "texte": "Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?" + } + ] + }, + { + "numero": 4, + "title": "Arrivée à l'abbaye", + "GPS": "N 46 13.024 E 5 14.160", + "indice": "L'année inscrite au-dessus du portail principal.", + "reponse": 1655, + "dialogue": [ + { + "personnage": "Claire", + "texte": "Voilà l'abbaye ! Admire l'architecture." + }, + { + "personnage": "Nathalie", + "texte": "C'est ici la dernière étape. Observez bien la date !" + } + ] + } + ] +} diff --git a/mainwindow.cpp b/mainwindow.cpp index b37664a..224cb9a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include "path.h" +#include "step.h" #include "Undo.h" #include #include @@ -84,6 +85,7 @@ void MainWindow::loadPath() file.close(); Path* p = new Path(&file); + QList steps = p->getStep(); currentPath = p; path.append(p); @@ -93,8 +95,24 @@ void MainWindow::loadPath() ui->lengthSpin->setValue(p->getLength()); ui->durationSpin->setValue(p->getDuration()); ui->imagePath->setText(p->getImage()); - loadImage(p->getImage()); + + if(!steps.isEmpty()) { + Step firstStep = p->getStep().first(); + ui->stepTitle->setText(firstStep.getTitle()); + ui->LatitudeSpin->setValue(firstStep.getLatitude()); + ui->longitudeSpin->setValue(firstStep.getLongitude()); + + for(int i = 0; i < firstStep.getTexte().length(); i++) { + QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i); + ui->dialogEdit->appendPlainText(q); + } + } + + int pathCount = path.length(); + ui->pathNumber->setMaximum(pathCount); + ui->pathNumber->setSuffix("/" + QString::number(pathCount)); + ui->pathNumber->setValue(path.indexOf(currentPath)+1); } void MainWindow::addNewPath() diff --git a/mainwindow.ui b/mainwindow.ui index 2f533da..9f5614c 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,9 +7,21 @@ 0 0 800 - 626 + 598 + + + 0 + 0 + + + + + 0 + 0 + + MainWindow @@ -57,7 +69,7 @@ QFrame::Shadow::Raised - + 10 @@ -285,13 +297,148 @@ - + + + + 0 + 0 + + QFrame::Shape::StyledPanel QFrame::Shadow::Raised + + + + 0 + 10 + 781 + 45 + + + + + + + 1 + + + + + + + + + + ... + + + + :/data/images/data/images/add.png:/data/images/data/images/add.png + + + + + + + + + 0 + 60 + 781 + 63 + + + + + + + + + + Latitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + 90.000000000000000 + + + + + + + + + + + + + Longitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + + + Response + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + + + + + + + + 10 + 130 + 761 + 81 + + + diff --git a/path.cpp b/path.cpp index 7a421f7..26a2558 100644 --- a/path.cpp +++ b/path.cpp @@ -75,7 +75,7 @@ Path::Path(QFile *file){ QJsonArray stepsArray = json["steps"].toArray(); for (const QJsonValue &stepValue : stepsArray) { QJsonObject stepObj = stepValue.toObject(); - //step.append(Step(stepObj)); + step.append(Step(stepObj)); } } diff --git a/step.cpp b/step.cpp index 861f414..1398647 100644 --- a/step.cpp +++ b/step.cpp @@ -34,6 +34,16 @@ Step::Step() { } +QList Step::getPersonnage() const +{ + return personnage; +} + +QList Step::getTexte() const +{ + return texte; +} + Step::Step( QJsonObject &in) { title = in["title"].toString(); @@ -41,7 +51,7 @@ Step::Step( QJsonObject &in) QString gps = in["GPS"].toString(); QStringList parts = gps.split(" ", Qt::SkipEmptyParts); - QChar latDir = parts[0][0]; // c'est le premier QChar du QString t'as capté + QChar latDir = parts[0][0]; int latDeg = parts[1].toInt(); float latMin = parts[2].toFloat(); setLatitude(latDeg, latMin, latDir); diff --git a/step.h b/step.h index 8d93c46..1607679 100644 --- a/step.h +++ b/step.h @@ -26,6 +26,8 @@ public: float getLatitude() const; float getLongitude() const; int getResponse() const; + QList getPersonnage() const; + QList getTexte() const; }; #endif // STEP_H