Modification du score
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package fr.monkhanny.dorfromantik.enums;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
|
||||
public enum Fonts {
|
||||
TITLE, BUTTON;
|
||||
TITLE, BUTTON, SCORE;
|
||||
|
||||
public String getFontPath() {
|
||||
switch (this) {
|
||||
@@ -9,8 +14,29 @@ public enum Fonts {
|
||||
return "./ressources/fonts/Contage-Black.ttf";
|
||||
case BUTTON:
|
||||
return "./ressources/fonts/Contage-Regular.ttf";
|
||||
case SCORE:
|
||||
return "./ressources/fonts/Contage-Bold.ttf";
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected value: " + this);
|
||||
}
|
||||
}
|
||||
|
||||
public Font getFont(float size) {
|
||||
try {
|
||||
switch (this) {
|
||||
case TITLE:
|
||||
return Font.createFont(Font.TRUETYPE_FONT, new File("./ressources/fonts/Contage-Black.ttf")).deriveFont(size);
|
||||
case BUTTON:
|
||||
return Font.createFont(Font.TRUETYPE_FONT, new File("./ressources/fonts/Contage-Regular.ttf")).deriveFont(size);
|
||||
case SCORE:
|
||||
return Font.createFont(Font.TRUETYPE_FONT, new File("./ressources/fonts/Contage-Bold.ttf")).deriveFont(size);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected value: " + this);
|
||||
}
|
||||
} catch (IOException | FontFormatException e) {
|
||||
e.printStackTrace();
|
||||
// Retourner une police de secours si le fichier est introuvable ou s'il y a une erreur
|
||||
return new Font("Arial", Font.PLAIN, (int) size);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user