Ajout de nouvelles étapes au tutoriel avec des descriptions améliorées + améliorations
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user