Ajout de nouvelles étapes au tutoriel avec des descriptions améliorées + améliorations

This commit is contained in:
2024-12-07 23:34:39 +01:00
parent cd22460ab8
commit 79857ac00c
33 changed files with 49 additions and 10 deletions

View File

@@ -120,13 +120,15 @@ public class TutorialPanel extends JPanel {
private void updateStepDisplay() {
Step currentStep = steps.get(currentStepIndex);
stepText.setText(currentStep.getText());
String formattedText = addLineBreaks(currentStep.getText(), 10); // Limite à 10 mots par ligne
stepText.setText(formattedText);
stepImage.setIcon(new ImageIcon(currentStep.getImagePath()));
stepImage.setHorizontalAlignment(JLabel.CENTER);
stepImage.setVerticalAlignment(JLabel.CENTER);
prevButton.setEnabled(currentStepIndex > 0);
nextButton.setEnabled(currentStepIndex < steps.size() - 1);
}
private void styleButton(JButton button) {
// Police et taille
@@ -177,4 +179,22 @@ public class TutorialPanel extends JPanel {
return returnButton;
}
private String addLineBreaks(String text, int maxWordsPerLine) {
String[] words = text.split(" ");
StringBuilder formattedText = new StringBuilder("<html>");
int wordCount = 0;
for (String word : words) {
formattedText.append(word).append(" ");
wordCount++;
if (wordCount >= maxWordsPerLine) {
formattedText.append("<br>");
wordCount = 0;
}
}
formattedText.append("</html>");
return formattedText.toString();
}
}