diff --git a/index.html b/index.html index 376df10..085c33d 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,6 @@ font-family: Arial; margin: 40px; background-color: whitesmoke; - } h1 { text-align: center; @@ -30,7 +29,7 @@ transition: background-color 0.3s ease; } li:hover { - background-color:black; + background-color: black; } a { text-decoration: none; @@ -46,8 +45,7 @@

Liste des parcours

+
  • Bourg
  • + diff --git a/mainwindow.cpp b/mainwindow.cpp index 92ddc8a..84471cc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -137,7 +137,7 @@ void MainWindow::loadPath(Path* p) { ui->longitudeSpin->setValue(firstStep.getLongitude()); for(int i = 0; i < firstStep.getTexte().length(); i++) { - QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i); + QString q = "[" + firstStep.getPersonnage().at(i) + "] : " + firstStep.getTexte().at(i); ui->dialogEdit->appendPlainText(q); } @@ -174,13 +174,29 @@ void MainWindow::addNewStep() void MainWindow::exportHTMLMap(int index) { - std::ofstream file("./pages/parcours" + std::to_string(index) + ".html"); - - if (!file.is_open()) { - QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier."); + if (index < 0 || index >= path.size()) { + QMessageBox::warning(this, "Erreur", "Index de parcours invalide."); return; } + Path* p = path[index]; + if (!p) { + QMessageBox::warning(this, "Erreur", "Le parcours sélectionné est nul."); + return; + } + + + + QString safeName = p->getName().simplified().replace(" ", "_"); + std::string fileName = "./pages/parcours_" + safeName.toStdString() + ".html"; + std::ofstream file(fileName); + + if (!file.is_open()) { + QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier HTML."); + return; + } + + // Début HTML file << R"( @@ -216,18 +232,17 @@ void MainWindow::exportHTMLMap(int index) border-radius: 5%; } #fiche ul { - padding-left: 20px; - list-style-type: disc; - overflow-wrap: break-word; - word-wrap: break-word; - word-break: break-word; - white-space: normal; - max-width: 90%; -} - + padding-left: 20px; + list-style-type: disc; + overflow-wrap: break-word; + word-wrap: break-word; + word-break: break-word; + white-space: normal; + max-width: 90%; + } #fiche li { - white-space: normal; - overflow-wrap: break-word; + white-space: normal; + overflow-wrap: break-word; } body h1 { display:flex; @@ -253,114 +268,122 @@ void MainWindow::exportHTMLMap(int index) -

    Fiche du parcours

    -
    -
    -
    + +

    Fiche du parcours

    +
    +
    +
    )"; - if (currentPath) { - Path* p = currentPath; - file << "

    " << p->getName().toStdString() << "

    \n"; - file << "

    Ville : " << p->getCity().toStdString() << "

    \n"; - file << "

    Département : " << p->getDepartement() << "

    \n"; - file << "

    Difficulté : " << p->getDifficulty() << "

    \n"; - file << "

    Durée (heures) : " << p->getDuration() << "

    \n"; - file << "

    Longueur (km) : " << p->getLength() << "

    \n"; - if (!p->getImage().isEmpty()) { - file << "getImage().toStdString() << "\">\n"; - } - int stepNum = 1; - for (const Step& s : p->getStep()) { - file << "

    Étape " << stepNum << "

    \n"; - const QList persos = s.getPersonnage(); - const QList textes = s.getTexte(); + // Infos du parcours + file << "

    " << p->getName().toStdString() << "

    \n"; + file << "

    Ville : " << p->getCity().toStdString() << "

    \n"; + file << "

    Département : " << p->getDepartement() << "

    \n"; + file << "

    Difficulté : " << p->getDifficulty() << "

    \n"; + file << "

    Durée (heures) : " << p->getDuration() << "

    \n"; + file << "

    Longueur (km) : " << p->getLength() << "

    \n"; - if (!persos.isEmpty()) { - file << "

    Personnages :

    \n
      "; - for (const QString& pers : persos) { - file << "
    • " << pers.toStdString() << "
    • \n"; - } - file << "
    \n"; + if (!p->getImage().isEmpty()) { + QString imagePath = p->getImage(); + QFileInfo fileInfo(imagePath); + QString imageName = fileInfo.fileName(); + QString destPath = "./pages/images/" + imageName; + + // Crée le dossier images s’il n’existe pas + QDir().mkpath("./pages/images"); + + // Copie l’image dans le dossier pages/images + QFile::copy(imagePath, destPath); + + // Utilisation dans le HTML + file << "\n"; + } + + + int stepNum = 1; + for (const Step& s : p->getStep()) { + file << "

    Étape " << stepNum << "

    \n"; + + const QList persos = s.getPersonnage(); + const QList textes = s.getTexte(); + + if (!persos.isEmpty()) { + file << "

    Personnages :

    \n
      "; + for (const QString& pers : persos) { + file << "
    • " << pers.toStdString() << "
    • \n"; } - - if (!textes.isEmpty()) { - file << "

      Dialogues :

      \n
        "; - for (const QString& txt : textes) { - file << "
      • " << txt.toStdString() << "
      • \n"; - } - file << "
      \n"; - } - - stepNum++; + file << "
    \n"; } + + if (!textes.isEmpty()) { + file << "

    Dialogues :

    \n
      "; + for (const QString& txt : textes) { + file << "
    • " << txt.toStdString() << "
    • \n"; + } + file << "
    \n"; + } + + stepNum++; } file << R"( -
    -
    +
    +
    - - + + var polyline = L.polyline(latlngs, { + color: 'purple', + weight: 2, + dashArray: '10, 10', + opacity: 0.7 + }).addTo(map); + map.fitBounds(polyline.getBounds()); + )"; @@ -369,6 +392,7 @@ void MainWindow::exportHTMLMap(int index) + void MainWindow::loadImage(QString fileName) { QString ext[] = {"png", "jpeg", "jpg"}; @@ -599,16 +623,59 @@ void MainWindow::on_stepNumber_valueChanged(int arg1) void MainWindow::on_validateBtn_clicked() { - currentPath->setName(ui->titleEdit->text()); - currentPath->setCity(ui->locEdit->text()); - currentPath->setImage(ui->imagePath->text()); - currentPath->setLength(ui->lengthSpin->value()); - currentPath->setDifficulty(ui->diffSpin->value()); - currentPath->setDuration(ui->durationSpin->value()); - currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); - currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); + this->currentPath->setName(ui->titleEdit->text()); + this->currentPath->setCity(ui->locEdit->text()); + this->currentPath->setImage(ui->imagePath->text()); + this->currentPath->setLength(ui->lengthSpin->value()); + this->currentPath->setDifficulty(ui->diffSpin->value()); + this->currentPath->setDuration(ui->durationSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); + this->currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearPersonnages(); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearTextes(); + extractDialogue(); } + +void MainWindow::extractDialogue() { + std::string texte = ui->dialogEdit->toPlainText().toStdString(); + size_t currentPosition = 0; + + while (currentPosition < texte.length()) { + size_t startPersonnage = texte.find('[', currentPosition); + if (startPersonnage == std::string::npos) break; + size_t endPersonnage = texte.find(']', startPersonnage); + if (endPersonnage == std::string::npos) break; + std::string nomPersonnage = texte.substr(startPersonnage + 1, endPersonnage - startPersonnage - 1); + + size_t startDialogue = texte.find(':', endPersonnage); + if (startDialogue == std::string::npos) break; + startDialogue += 2; + size_t endDialogue = startDialogue; + while (endDialogue < texte.length()) { + size_t nextNewLine = texte.find('\n', endDialogue); + if (nextNewLine == std::string::npos) { + endDialogue = texte.length(); + break; + } + size_t nextPersonnageStart = texte.find('[', nextNewLine); + if (nextPersonnageStart != std::string::npos && nextPersonnageStart < nextNewLine + nomPersonnage.length() + 3) { + endDialogue = nextNewLine; + break; + } + endDialogue = nextNewLine + 1; + } + std::string dialogue = texte.substr(startDialogue, endDialogue - startDialogue); + + currentPath->getStep()[ui->stepNumber->value()-1].addPersonnage(QString::fromStdString(nomPersonnage)); + currentPath->getStep()[ui->stepNumber->value()-1].addTexte(QString::fromStdString(dialogue)); + currentPosition = endDialogue; + } +} + + + + void MainWindow::loadAndExportPaths(QStringList fichiers) { @@ -902,6 +969,7 @@ void MainWindow::newPath(){ currentPath = p; path.append(p); loadPath(p); + p->addStep(); int pathCount = path.length(); ui->pathNumber->setMaximum(pathCount); @@ -929,5 +997,4 @@ void MainWindow::on_actionFont_color_triggered() void MainWindow::on_addStep_clicked() { this->addNewStep(); -} - +} \ No newline at end of file diff --git a/mainwindow.h b/mainwindow.h index 0839c0a..1ad0360 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -51,6 +51,7 @@ public: void setFont(); void saveFile(); void newPath(); + void extractDialogue(); private slots: void on_pushButton_clicked(); diff --git a/pages/images/logo.png b/pages/images/logo.png new file mode 100644 index 0000000..03ece10 Binary files /dev/null and b/pages/images/logo.png differ diff --git a/pages/parcours0.html b/pages/parcours0.html deleted file mode 100644 index 7f4959a..0000000 --- a/pages/parcours0.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - Carte du parcours - - - - - -

    Fiche du parcours

    -
    -
    -
    -

    parcous123

    -

    Ville : Bourg en bresse

    -

    Département : 0

    -

    Difficulté : 2

    -

    Durée (heures) : 2.3

    -

    Longueur (km) : 17.3

    - -

    Étape 1

    -

    Personnages :

    - -

    Dialogues :

    - -

    Étape 2

    -

    Personnages :

    - -

    Dialogues :

    - - -
    -
    - - - - - diff --git a/pages/parcours1.html b/pages/parcours1.html deleted file mode 100644 index 7f4959a..0000000 --- a/pages/parcours1.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - Carte du parcours - - - - - -

    Fiche du parcours

    -
    -
    -
    -

    parcous123

    -

    Ville : Bourg en bresse

    -

    Département : 0

    -

    Difficulté : 2

    -

    Durée (heures) : 2.3

    -

    Longueur (km) : 17.3

    - -

    Étape 1

    -

    Personnages :

    - -

    Dialogues :

    - -

    Étape 2

    -

    Personnages :

    - -

    Dialogues :

    - - -
    -
    - - - - - diff --git a/step.cpp b/step.cpp index 419f676..18c87b5 100644 --- a/step.cpp +++ b/step.cpp @@ -37,6 +37,22 @@ QList Step::getTexte() const return texte; } +void Step::addPersonnage(const QString& pers) { + personnage.append(pers); +} + +void Step::addTexte(const QString& txt) { + texte.append(txt); +} + +void Step::clearPersonnages() { + personnage.clear(); +} + +void Step::clearTextes() { + texte.clear(); +} + void Step::setTitle(const QString &newTitle) { title = newTitle; diff --git a/step.h b/step.h index eb2bc9e..6746ed9 100644 --- a/step.h +++ b/step.h @@ -33,6 +33,10 @@ public: void setPersonnage(const QList &newPersonnage); void setTexte(const QList &newTexte); QString toGPSFormat(); + void addPersonnage(const QString& pers) ; + void addTexte(const QString& txt); + void clearPersonnages(); + void clearTextes(); }; #endif // STEP_H diff --git a/web.cpp b/web.cpp index 7dd0a2d..f6ea24b 100644 --- a/web.cpp +++ b/web.cpp @@ -24,7 +24,6 @@ void Web::siteHtml() font-family: Arial; margin: 40px; background-color: whitesmoke; - } h1 { text-align: center; @@ -46,7 +45,7 @@ void Web::siteHtml() transition: background-color 0.3s ease; } li:hover { - background-color:black; + background-color: black; } a { text-decoration: none; @@ -64,22 +63,25 @@ void Web::siteHtml() + file << R"( )"; file.close(); } +