Fichiers
gastinel-client/src/main/java/com/gastinelclient/ui/Charte.java
T

79 lignes
2.9 KiB
Java

package com.gastinelclient.ui;
import com.gastinelclient.GastinelClient;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
/**
* Charte Gastinel : papier réchauffé, encre presque noire, filets fins, aucun arrondi,
* police Inter, et quelques couleurs franches réservées aux éléments clés.
*/
public final class Charte {
private Charte() {}
// Couleurs (ARGB)
public static final int PAPIER = 0xFFF2F0E6;
public static final int CARTE = 0xFFF8F7F1;
public static final int SURVOL = 0xFFE9E5D9;
public static final int ENCRE = 0xFF2D2A26;
public static final int DOUX = 0xFF6F6A61;
public static final int FILET = 0xFFDAD5C8;
public static final int FILET_FORT = 0xFFB9B1A0;
// Accents francs (avec retenue)
public static final int ORANGE = 0xFFE8590C;
public static final int VERT = 0xFF2B8A3E;
public static final int ROUGE = 0xFFC92A2A;
public static final ResourceLocation INTER = rl("inter");
public static final ResourceLocation INTER_GRAS = rl("inter_gras");
public static final ResourceLocation INTER_TITRE = rl("inter_titre");
public static final ResourceLocation FOND = rl("textures/gui/fond.png");
private static final int FOND_L = 1920, FOND_H = 1080;
private static ResourceLocation rl(String p) {
return ResourceLocation.fromNamespaceAndPath(GastinelClient.MODID, p);
}
public static MutableComponent txt(String s) {
return Component.literal(s).withStyle(st -> st.withFont(INTER));
}
public static MutableComponent gras(String s) {
return Component.literal(s).withStyle(st -> st.withFont(INTER_GRAS));
}
public static MutableComponent titre(String s) {
return Component.literal(s).withStyle(st -> st.withFont(INTER_TITRE));
}
/** Texte sans ombre (l'ombre vanilla salit un fond clair). */
public static void texte(GuiGraphics g, Font f, Component c, int x, int y, int couleur) {
g.drawString(f, c, x, y, couleur, false);
}
/** Grand titre : police Inter suréchantillonnée, agrandie d'un facteur {@code echelle}. */
public static void grandTitre(GuiGraphics g, Font f, String s, int x, int y, float echelle, int couleur) {
g.pose().pushPose();
g.pose().translate(x, y, 0);
g.pose().scale(echelle, echelle, 1f);
g.drawString(f, titre(s), 0, 0, couleur, false);
g.pose().popPose();
}
/** Arrière-plan « à lui » : papier + courbes de niveau, calé à droite, recouvrant tout l'écran. */
public static void fond(GuiGraphics g, int w, int h) {
g.fill(0, 0, w, h, PAPIER);
float k = Math.max(w / (float) FOND_L, h / (float) FOND_H);
int dw = Math.round(FOND_L * k), dh = Math.round(FOND_H * k);
g.blit(FOND, w - dw, (h - dh) / 2, dw, dh, 0f, 0f, FOND_L, FOND_H, FOND_L, FOND_H);
}
/** Filet horizontal fin. */
public static void filet(GuiGraphics g, int x1, int x2, int y, int couleur) {
g.fill(x1, y, x2, y + 1, couleur);
}
}